aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CREDITS5
-rw-r--r--ChangeLog2
-rw-r--r--examples/bsg_queue_tst.c8
-rw-r--r--examples/sg_excl.c5
-rw-r--r--examples/sg_iovec_tst.c3
-rw-r--r--examples/sg_sense_test.c4
-rw-r--r--examples/sg_simple1.c5
-rw-r--r--examples/sg_simple2.c7
-rw-r--r--examples/sg_simple3.c5
-rw-r--r--examples/sg_simple_aio.c5
-rw-r--r--include/sg_pt_win32.h18
-rw-r--r--lib/sg_cmds_basic.c1
-rw-r--r--lib/sg_cmds_extra.c20
-rw-r--r--lib/sg_lib.c3
-rw-r--r--lib/sg_pt_common.c1
-rw-r--r--lib/sg_pt_freebsd.c2
-rw-r--r--lib/sg_pt_linux.c6
-rw-r--r--lib/sg_pt_osf1.c3
-rw-r--r--src/sg_dd.c49
-rw-r--r--src/sg_decode_sense.c2
-rw-r--r--src/sg_emc_trespass.c6
-rw-r--r--src/sg_format.c2
-rw-r--r--src/sg_get_config.c2
-rw-r--r--src/sg_get_lba_status.c2
-rw-r--r--src/sg_inq.c16
-rw-r--r--src/sg_inq_data.c1
-rw-r--r--src/sg_logs.c29
-rw-r--r--src/sg_map.c1
-rw-r--r--src/sg_modes.c4
-rw-r--r--src/sg_persist.c14
-rw-r--r--src/sg_raw.c2
-rw-r--r--src/sg_read.c47
-rw-r--r--src/sg_read_buffer.c6
-rw-r--r--src/sg_sanitize.c16
-rw-r--r--src/sg_scan.c.linux56
-rw-r--r--src/sg_scan.c.win3254
-rw-r--r--src/sg_ses.c25
-rw-r--r--src/sg_stpg.c12
-rw-r--r--src/sg_vpd.c10
-rw-r--r--src/sg_vpd_vendor.c21
-rw-r--r--src/sg_write_same.c2
-rw-r--r--src/sg_xcopy.c57
-rw-r--r--src/sginfo.c281
-rw-r--r--src/sgm_dd.c43
-rw-r--r--src/sgp_dd.c74
-rw-r--r--utils/sg_chk_asc.c5
46 files changed, 547 insertions, 395 deletions
diff --git a/CREDITS b/CREDITS
index 7f9dfa4e..d3359507 100644
--- a/CREDITS
+++ b/CREDITS
@@ -93,6 +93,9 @@ Ronnie Sahlberg <ronniesahlberg at gmail dot com> has written libiscsi and a
Saeed Bishara contributed sg_write_long
+Shahar Salzman <shahar dot salzman at kaminario dot com> contributed
+ sg_compare_and_write [20121205]
+
Thomas Kolbe <tkolbe at partnersdata dot com>
Solaris port help and testing [20070503]
@@ -107,4 +110,4 @@ Trent Piepho <xyzzy at speakeasy dot org> print out some "sense key specific"
Douglas Gilbert
-22nd March 2012
+10th December 2012
diff --git a/ChangeLog b/ChangeLog
index 2e4224be..db3469ef 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.35 [20121208] [svn: r469]
+Changelog for sg3_utils-1.35 [20121211] [svn: r470]
- sg_compare_and_write: new utility
- sg_inq+sg_vpd: block device characteristics VPD page:
add product_type, WABEREQ, WACEREQ and VBULS fields
diff --git a/examples/bsg_queue_tst.c b/examples/bsg_queue_tst.c
index 998c4958..b376dc8a 100644
--- a/examples/bsg_queue_tst.c
+++ b/examples/bsg_queue_tst.c
@@ -138,8 +138,8 @@ int main(int argc, char * argv[])
if (0 == rio_hdr.device_status)
ok = 1;
else {
- switch (sg_err_category_sense((unsigned char *)(long)rio_hdr.response,
- rio_hdr.response_len)) {
+ switch (sg_err_category_sense((unsigned char *)(long)
+ rio_hdr.response, rio_hdr.response_len)) {
case SG_LIB_CAT_CLEAN:
ok = 1;
break;
@@ -158,8 +158,8 @@ int main(int argc, char * argv[])
if (ok) { /* output result if it is available */
/* if (0 == rio_hdr.pack_id) */
if (0 == (rio_hdr.usr_ptr % 3))
- printf("SEND DIAGNOSTIC %d duration=%u\n", (int)rio_hdr.usr_ptr,
- rio_hdr.duration);
+ printf("SEND DIAGNOSTIC %d duration=%u\n",
+ (int)rio_hdr.usr_ptr, rio_hdr.duration);
else
printf("INQUIRY %d duration=%u\n", (int)rio_hdr.usr_ptr,
rio_hdr.duration);
diff --git a/examples/sg_excl.c b/examples/sg_excl.c
index 6e651a88..743b9fa1 100644
--- a/examples/sg_excl.c
+++ b/examples/sg_excl.c
@@ -188,8 +188,9 @@ int main(int argc, char * argv[])
printf("Test Unit Ready failed so unit may _not_ be ready!\n");
if (do_extra)
- printf("TEST UNIT READY duration=%u millisecs, resid=%d, msg_status=%d\n",
- io_hdr.duration, io_hdr.resid, (int)io_hdr.msg_status);
+ printf("TEST UNIT READY duration=%u millisecs, resid=%d, "
+ "msg_status=%d\n", io_hdr.duration, io_hdr.resid,
+ (int)io_hdr.msg_status);
sleep(60);
close(sg_fd);
diff --git a/examples/sg_iovec_tst.c b/examples/sg_iovec_tst.c
index 83ccf593..9f8bbe3c 100644
--- a/examples/sg_iovec_tst.c
+++ b/examples/sg_iovec_tst.c
@@ -150,7 +150,8 @@ int main(int argc, char * argv[])
printf(" where: -h this usage message\n");
printf(" -b=num block size (default 512 Bytes)\n");
printf(" -c=num count of blocks to transfer\n");
- printf(" reads from <generic_device> and sends to <output_filename>\n");
+ printf(" reads from <generic_device> and sends to "
+ "<output_filename>\n");
return 1;
}
diff --git a/examples/sg_sense_test.c b/examples/sg_sense_test.c
index d91157cf..56f1d9c8 100644
--- a/examples/sg_sense_test.c
+++ b/examples/sg_sense_test.c
@@ -45,8 +45,8 @@ int main(/* int argc, char * argv[] */)
0x3, 0x2, 0, 0x55,
0x5, 0x2, 0, 0x20,
0x85, 0x4, 0, 0x20, 0x33, 0x44};
- unsigned char err5[] = {0xf1, 0, (0xf0 | SPC_SK_ILLEGAL_REQUEST), 0x11, 0x22,
- 0x33, 0x44, 0xa,
+ unsigned char err5[] = {0xf1, 0, (0xf0 | SPC_SK_ILLEGAL_REQUEST), 0x11,
+ 0x22, 0x33, 0x44, 0xa,
0x0, 0x0, 0, 0, 0x4, 0x1, 0, 0xcf, 0, 5,};
unsigned char err6[] = {0x72, SPC_SK_NO_SENSE, 0x4, 0x1, 0, 0, 0, 14,
0x9, 0xc, 1, 0, 0x11, 0x22, 0x66, 0x33,
diff --git a/examples/sg_simple1.c b/examples/sg_simple1.c
index f25414cc..73ba76e9 100644
--- a/examples/sg_simple1.c
+++ b/examples/sg_simple1.c
@@ -180,8 +180,9 @@ int main(int argc, char * argv[])
printf("Test Unit Ready failed so unit may _not_ be ready!\n");
if (do_extra)
- printf("TEST UNIT READY duration=%u millisecs, resid=%d, msg_status=%d\n",
- io_hdr.duration, io_hdr.resid, (int)io_hdr.msg_status);
+ printf("TEST UNIT READY duration=%u millisecs, resid=%d, "
+ "msg_status=%d\n", io_hdr.duration, io_hdr.resid,
+ (int)io_hdr.msg_status);
close(sg_fd);
return 0;
diff --git a/examples/sg_simple2.c b/examples/sg_simple2.c
index a0da0e4f..a4763b54 100644
--- a/examples/sg_simple2.c
+++ b/examples/sg_simple2.c
@@ -81,7 +81,7 @@ int main(int argc, char * argv[])
/* N.B. An access mode of O_RDWR is required for some SCSI commands */
if ((sg_fd = open(file_name, O_RDONLY)) < 0) {
snprintf(ebuff, EBUFF_SZ,
- "sg_simple2: error opening file: %s", file_name);
+ "sg_simple2: error opening file: %s", file_name);
perror(ebuff);
return 1;
}
@@ -188,8 +188,9 @@ int main(int argc, char * argv[])
printf("Test Unit Ready successful so unit is ready!\n");
/* Extra info, not necessary to look at */
if (do_extra)
- printf("TEST UNIT READY duration=%u millisecs, resid=%d, msg_status=%d\n",
- io_hdr.duration, io_hdr.resid, (int)io_hdr.msg_status);
+ printf("TEST UNIT READY duration=%u millisecs, resid=%d, "
+ "msg_status=%d\n", io_hdr.duration, io_hdr.resid,
+ (int)io_hdr.msg_status);
close(sg_fd);
return 0;
diff --git a/examples/sg_simple3.c b/examples/sg_simple3.c
index 0ee26843..93f2971e 100644
--- a/examples/sg_simple3.c
+++ b/examples/sg_simple3.c
@@ -196,8 +196,9 @@ int main(int argc, char * argv[])
printf("Test Unit Ready failed so unit may _not_ be ready!\n");
if (do_extra)
- printf("TEST UNIT READY duration=%u millisecs, resid=%d, msg_status=%d\n",
- io_hdr.duration, io_hdr.resid, (int)io_hdr.msg_status);
+ printf("TEST UNIT READY duration=%u millisecs, resid=%d, "
+ "msg_status=%d\n", io_hdr.duration, io_hdr.resid,
+ (int)io_hdr.msg_status);
close(sg_fd);
return 0;
diff --git a/examples/sg_simple_aio.c b/examples/sg_simple_aio.c
index e4e8622f..95dfcfa2 100644
--- a/examples/sg_simple_aio.c
+++ b/examples/sg_simple_aio.c
@@ -230,8 +230,9 @@ int main(int argc, char * argv[])
printf("Test Unit Ready failed so unit may _not_ be ready!\n");
if (do_extra)
- printf("TEST UNIT READY duration=%u millisecs, resid=%d, msg_status=%d\n",
- io_hdr.duration, io_hdr.resid, (int)io_hdr.msg_status);
+ printf("TEST UNIT READY duration=%u millisecs, resid=%d, "
+ "msg_status=%d\n", io_hdr.duration, io_hdr.resid,
+ (int)io_hdr.msg_status);
close(sg_fd);
return 0;
diff --git a/include/sg_pt_win32.h b/include/sg_pt_win32.h
index f098dcd2..53366ecd 100644
--- a/include/sg_pt_win32.h
+++ b/include/sg_pt_win32.h
@@ -138,11 +138,17 @@ typedef struct {
(((DevType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
#endif
-#define IOCTL_SCSI_PASS_THROUGH CTL_CODE(IOCTL_SCSI_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
-#define IOCTL_SCSI_MINIPORT CTL_CODE(IOCTL_SCSI_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
-#define IOCTL_SCSI_GET_INQUIRY_DATA CTL_CODE(IOCTL_SCSI_BASE, 0x0403, METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define IOCTL_SCSI_GET_CAPABILITIES CTL_CODE(IOCTL_SCSI_BASE, 0x0404, METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define IOCTL_SCSI_PASS_THROUGH_DIRECT CTL_CODE(IOCTL_SCSI_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
-#define IOCTL_SCSI_GET_ADDRESS CTL_CODE(IOCTL_SCSI_BASE, 0x0406, METHOD_BUFFERED, FILE_ANY_ACCESS)
+#define IOCTL_SCSI_PASS_THROUGH CTL_CODE(IOCTL_SCSI_BASE, 0x0401, \
+ METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
+#define IOCTL_SCSI_MINIPORT CTL_CODE(IOCTL_SCSI_BASE, 0x0402, \
+ METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
+#define IOCTL_SCSI_GET_INQUIRY_DATA CTL_CODE(IOCTL_SCSI_BASE, 0x0403, \
+ METHOD_BUFFERED, FILE_ANY_ACCESS)
+#define IOCTL_SCSI_GET_CAPABILITIES CTL_CODE(IOCTL_SCSI_BASE, 0x0404, \
+ METHOD_BUFFERED, FILE_ANY_ACCESS)
+#define IOCTL_SCSI_PASS_THROUGH_DIRECT CTL_CODE(IOCTL_SCSI_BASE, 0x0405, \
+ METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
+#define IOCTL_SCSI_GET_ADDRESS CTL_CODE(IOCTL_SCSI_BASE, 0x0406, \
+ METHOD_BUFFERED, FILE_ANY_ACCESS)
#endif
diff --git a/lib/sg_cmds_basic.c b/lib/sg_cmds_basic.c
index 2ff71abb..7ab5dc99 100644
--- a/lib/sg_cmds_basic.c
+++ b/lib/sg_cmds_basic.c
@@ -588,4 +588,3 @@ sg_ll_report_luns(int sg_fd, int select_report, void * resp, int mx_resp_len,
destruct_scsi_pt_obj(ptvp);
return ret;
}
-
diff --git a/lib/sg_cmds_extra.c b/lib/sg_cmds_extra.c
index 48534b28..d162bb7c 100644
--- a/lib/sg_cmds_extra.c
+++ b/lib/sg_cmds_extra.c
@@ -328,8 +328,9 @@ sg_ll_set_tgt_prt_grp(int sg_fd, void * paramp, int param_len, int noisy,
* SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND,
* SG_LIB_CAT_UNIT_ATTENTION, -1 -> other failure */
int
-sg_ll_report_referrals(int sg_fd, uint64_t start_llba, int one_seg, void * resp,
- int mx_resp_len, int noisy, int verbose)
+sg_ll_report_referrals(int sg_fd, uint64_t start_llba, int one_seg,
+ void * resp, int mx_resp_len, int noisy,
+ int verbose)
{
int k, res, ret, sense_cat;
unsigned char repRefCmdBlk[SERVICE_ACTION_IN_16_CMDLEN] =
@@ -939,7 +940,8 @@ sg_ll_reassign_blocks(int sg_fd, int longlba, int longlist, void * paramp,
unsigned char sense_b[SENSE_BUFF_LEN];
struct sg_pt_base * ptvp;
- reassCmdBlk[1] = (unsigned char)(((longlba << 1) & 0x2) | (longlist & 0x1));
+ reassCmdBlk[1] = (unsigned char)(((longlba << 1) & 0x2) |
+ (longlist & 0x1));
if (NULL == sg_warnings_strm)
sg_warnings_strm = stderr;
if (verbose) {
@@ -1028,8 +1030,9 @@ sg_ll_persistent_reserve_in(int sg_fd, int rq_servact, void * resp,
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_in(ptvp, (unsigned char *)resp, mx_resp_len);
res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
- ret = sg_cmds_process_resp(ptvp, "persistent reservation in", res, mx_resp_len,
- sense_b, noisy, verbose, &sense_cat);
+ ret = sg_cmds_process_resp(ptvp, "persistent reservation in", res,
+ mx_resp_len, sense_b, noisy, verbose,
+ &sense_cat);
if (-1 == ret)
;
else if (-2 == ret) {
@@ -1089,7 +1092,8 @@ sg_ll_persistent_reserve_out(int sg_fd, int rq_servact, int rq_scope,
fprintf(sg_warnings_strm, "%02x ", proutCmdBlk[k]);
fprintf(sg_warnings_strm, "\n");
if (verbose > 1) {
- fprintf(sg_warnings_strm, " Persistent Reservation Out parameters:\n");
+ fprintf(sg_warnings_strm, " Persistent Reservation Out "
+ "parameters:\n");
dStrHex((const char *)paramp, param_len, 0);
}
}
@@ -2152,7 +2156,7 @@ sg_ll_read_block_limits(int sg_fd, void * resp, int mx_resp_len,
int noisy, int verbose)
{
int k, ret, res, sense_cat;
- unsigned char rlCmdBlk[READ_BLOCK_LIMITS_CMDLEN] =
+ unsigned char rlCmdBlk[READ_BLOCK_LIMITS_CMDLEN] =
{READ_BLOCK_LIMITS_CMD, 0, 0, 0, 0, 0};
unsigned char sense_b[SENSE_BUFF_LEN];
struct sg_pt_base * ptvp;
@@ -2341,5 +2345,3 @@ sg_ll_extended_copy(int sg_fd, void * resp,
destruct_scsi_pt_obj(ptvp);
return ret;
}
-
-
diff --git a/lib/sg_lib.c b/lib/sg_lib.c
index 1732dabb..5fda55d1 100644
--- a/lib/sg_lib.c
+++ b/lib/sg_lib.c
@@ -847,7 +847,7 @@ sg_get_sense_str(const char * leadin, const unsigned char * sense_buffer,
n = strlen(buff);
if (n >= buff_len)
return;
- } else if ((len > 12) && (0 == ssh.asc) &&
+ } else if ((len > 12) && (0 == ssh.asc) &&
(ASCQ_ATA_PT_INFO_AVAILABLE == ssh.ascq)) {
/* SAT ATA PASS-THROUGH fixed format */
n += snprintf(buff + n, buff_len - n, "%s\n",
@@ -1870,4 +1870,3 @@ sg_set_binary_mode(int fd)
}
#endif
-
diff --git a/lib/sg_pt_common.c b/lib/sg_pt_common.c
index 45b0710d..e6f1f871 100644
--- a/lib/sg_pt_common.c
+++ b/lib/sg_pt_common.c
@@ -21,4 +21,3 @@ scsi_pt_version()
{
return scsi_pt_version_str;
}
-
diff --git a/lib/sg_pt_freebsd.c b/lib/sg_pt_freebsd.c
index efb40095..b78019da 100644
--- a/lib/sg_pt_freebsd.c
+++ b/lib/sg_pt_freebsd.c
@@ -81,7 +81,7 @@ scsi_pt_open_device(const char * device_name, int read_only, int verbose)
oflags |= (read_only ? O_RDONLY : O_RDWR);
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. */
diff --git a/lib/sg_pt_linux.c b/lib/sg_pt_linux.c
index 2089e330..9d343735 100644
--- a/lib/sg_pt_linux.c
+++ b/lib/sg_pt_linux.c
@@ -79,7 +79,7 @@ static const char * linux_driver_suggests[] = {
#define SG_LIB_DRIVER_MASK DRIVER_MASK
#define SG_LIB_SUGGEST_MASK SUGGEST_MASK
#define SG_LIB_DRIVER_SENSE DRIVER_SENSE
-
+
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@@ -756,8 +756,8 @@ set_scsi_pt_flags(struct sg_pt_base * vp, int flags)
struct sg_pt_linux_scsi * ptp = &vp->impl;
/* default action of bsg (sg v4) is QUEUE_AT_HEAD */
- if (SCSI_PT_FLAGS_QUEUE_AT_TAIL & flags)
- ptp->io_hdr.flags |= BSG_FLAG_Q_AT_TAIL;
+ if (SCSI_PT_FLAGS_QUEUE_AT_TAIL & flags)
+ ptp->io_hdr.flags |= BSG_FLAG_Q_AT_TAIL;
if (SCSI_PT_FLAGS_QUEUE_AT_HEAD & flags)
ptp->io_hdr.flags &= ~BSG_FLAG_Q_AT_TAIL;
}
diff --git a/lib/sg_pt_osf1.c b/lib/sg_pt_osf1.c
index 15d660aa..dd2a824d 100644
--- a/lib/sg_pt_osf1.c
+++ b/lib/sg_pt_osf1.c
@@ -373,7 +373,8 @@ do_scsi_pt(struct sg_pt_base * vp, int device_fd, int time_secs, int verbose)
uagt.uagt_ccb = (CCB_HEADER *) &ccb;
uagt.uagt_ccblen = sizeof(ccb);
uagt.uagt_snsbuf = ccb.cam_sense_ptr = ptp->sense ? ptp->sense : sensep;
- uagt.uagt_snslen = ccb.cam_sense_len = ptp->sense ? ptp->sense_len : sizeof sensep;
+ uagt.uagt_snslen = ccb.cam_sense_len = ptp->sense ? ptp->sense_len :
+ sizeof sensep;
uagt.uagt_buffer = ccb.cam_data_ptr = ptp->dxferp;
uagt.uagt_buflen = ccb.cam_dxfer_len = ptp->dxfer_len;
diff --git a/src/sg_dd.c b/src/sg_dd.c
index b68bce27..d15d5a67 100644
--- a/src/sg_dd.c
+++ b/src/sg_dd.c
@@ -58,7 +58,7 @@
#include "sg_cmds_extra.h"
#include "sg_io_linux.h"
-static char * version_str = "5.75 20120907";
+static char * version_str = "5.75 20121211";
#define ME "sg_dd: "
@@ -192,8 +192,8 @@ print_stats(const char * str)
fprintf(stderr, " remaining block count=%"PRId64"\n", dd_count);
fprintf(stderr, "%s%"PRId64"+%d records in\n", str, in_full - in_partial,
in_partial);
- fprintf(stderr, "%s%"PRId64"+%d records out\n", str, out_full - out_partial,
- out_partial);
+ fprintf(stderr, "%s%"PRId64"+%d records out\n", str,
+ out_full - out_partial, out_partial);
if (oflag.sparse)
fprintf(stderr, "%s%"PRId64" bypassed records out\n", str, out_sparse);
if (recovered_errs > 0)
@@ -448,8 +448,8 @@ scsi_read_capacity(int sg_fd, int64_t * num_sect, int * sect_sz)
(rcBuff[6] << 8) | rcBuff[7];
}
if (verbose)
- fprintf(stderr, " number of blocks=%"PRId64" [0x%"PRIx64"], block "
- "size=%d\n", *num_sect, *num_sect, *sect_sz);
+ fprintf(stderr, " number of blocks=%"PRId64" [0x%"PRIx64"], "
+ "block size=%d\n", *num_sect, *num_sect, *sect_sz);
return 0;
}
@@ -474,8 +474,9 @@ read_blkdev_capacity(int sg_fd, int64_t * num_sect, int * sect_sz)
}
*num_sect = ((int64_t)ull / (int64_t)*sect_sz);
if (verbose)
- fprintf(stderr, " [bgs64] number of blocks=%"PRId64" [0x%"PRIx64"], "
- "block size=%d\n", *num_sect, *num_sect, *sect_sz);
+ fprintf(stderr, " [bgs64] number of blocks=%" PRId64 " [0x%"
+ PRIx64"], block size=%d\n", *num_sect, *num_sect,
+ *sect_sz);
#else
unsigned long ul;
@@ -485,8 +486,9 @@ read_blkdev_capacity(int sg_fd, int64_t * num_sect, int * sect_sz)
}
*num_sect = (int64_t)ul;
if (verbose)
- fprintf(stderr, " [bgs] number of blocks=%"PRId64" [0x%"PRIx64"], "
- " block size=%d\n", *num_sect, *num_sect, *sect_sz);
+ fprintf(stderr, " [bgs] number of blocks=%"PRId64" [0x%"
+ PRIx64 "], block size=%d\n", *num_sect, *num_sect,
+ *sect_sz);
#endif
}
return 0;
@@ -613,8 +615,8 @@ sg_read_low(int sg_fd, unsigned char * buff, int blocks, int64_t from_block,
if (sg_build_scsi_cdb(rdCmd, ifp->cdbsz, blocks, from_block, 0,
ifp->fua, ifp->dpo)) {
- fprintf(stderr, ME "bad rd cdb build, from_block=%"PRId64", blocks=%d\n",
- from_block, blocks);
+ fprintf(stderr, ME "bad rd cdb build, from_block=%" PRId64
+ ", blocks=%d\n", from_block, blocks);
return SG_LIB_SYNTAX_ERROR;
}
@@ -1703,8 +1705,8 @@ main(int argc, char * argv[])
if ((blk_sz >= 2048) && (0 == bpt_given))
bpt = DEF_BLOCKS_PER_2048TRANSFER;
#ifdef SG_DEBUG
- fprintf(stderr, ME "if=%s skip=%"PRId64" of=%s seek=%"PRId64" count=%"PRId64"\n",
- inf, skip, outf, seek, dd_count);
+ fprintf(stderr, ME "if=%s skip=%" PRId64 " of=%s seek=%" PRId64
+ " count=%" PRId64 "\n", inf, skip, outf, seek, dd_count);
#endif
install_handler(SIGINT, interrupt_handler);
install_handler(SIGQUIT, interrupt_handler);
@@ -1829,9 +1831,9 @@ main(int argc, char * argv[])
if (out_num_sect > seek)
out_num_sect -= seek;
#ifdef SG_DEBUG
- fprintf(stderr,
- "Start of loop, count=%"PRId64", in_num_sect=%"PRId64", out_num_sect=%"PRId64"\n",
- dd_count, in_num_sect, out_num_sect);
+ fprintf(stderr, "Start of loop, count=%" PRId64 ", in_num_sect=%"
+ PRId64 ", out_num_sect=%"PRId64"\n", dd_count, in_num_sect,
+ out_num_sect);
#endif
if (dd_count < 0) {
if (in_num_sect > 0) {
@@ -2014,20 +2016,20 @@ main(int argc, char * argv[])
off64_t off_res;
if (verbose > 2)
- fprintf(stderr, "sparse bypassing write: "
- "seek=%"PRId64", rel offset=%"PRId64"\n", (seek * blk_sz),
+ fprintf(stderr, "sparse bypassing write: seek=%" PRId64
+ ", rel offset=%" PRId64 "\n", (seek * blk_sz),
(int64_t)offset);
off_res = lseek64(outfd, offset, SEEK_CUR);
if (off_res < 0) {
- fprintf(stderr, "sparse tried to bypass write: "
- "seek=%"PRId64", rel offset=%"PRId64" but ...\n",
+ fprintf(stderr, "sparse tried to bypass write: seek=%"
+ PRId64 ", rel offset=%" PRId64 " but ...\n",
(seek * blk_sz), (int64_t)offset);
perror("lseek64 on output");
ret = SG_LIB_FILE_ERROR;
break;
} else if (verbose > 4)
- fprintf(stderr, "oflag=sparse lseek64 result=%"PRId64"\n",
- (int64_t)off_res);
+ fprintf(stderr, "oflag=sparse lseek64 result=%" PRId64
+ "\n", (int64_t)off_res);
out_sparse += blocks;
}
} else if (FT_SG & out_type) {
@@ -2108,7 +2110,8 @@ main(int argc, char * argv[])
ret = -1;
break;
} else if (res < blocks * blk_sz) {
- fprintf(stderr, "output file probably full, seek=%"PRId64" ", seek);
+ fprintf(stderr, "output file probably full, seek=%" PRId64
+ " ", seek);
blocks = res / blk_sz;
out_full += blocks;
if ((res % blk_sz) > 0)
diff --git a/src/sg_decode_sense.c b/src/sg_decode_sense.c
index 1ddcda65..aab1abd2 100644
--- a/src/sg_decode_sense.c
+++ b/src/sg_decode_sense.c
@@ -326,7 +326,7 @@ write2wfn(FILE * fp, struct opts_t * optsp)
n = 0;
}
}
- if (n > 0) {
+ if (n > 0) {
b[n] = '\n';
s = fwrite(b, 1, n + 1, fp);
}
diff --git a/src/sg_emc_trespass.c b/src/sg_emc_trespass.c
index 90f3dead..f3e0285f 100644
--- a/src/sg_emc_trespass.c
+++ b/src/sg_emc_trespass.c
@@ -39,7 +39,8 @@ static int do_trespass(int fd, int hr, int short_cmd)
{ 0, 0, 0, 0, 0, 0, 0, 0x00,
TRESPASS_PAGE, /* Page code */
0x09, /* Page length - 2 */
- 0x81, /* Trespass code + Honor reservation bit */
+ 0x81, /* Trespass code + Honor reservation
+ * bit */
0xff, 0xff, /* Trespass target */
0, 0, 0, 0, 0, 0 /* Reserved bytes / unknown */
};
@@ -47,7 +48,8 @@ static int do_trespass(int fd, int hr, int short_cmd)
{ 0, 0, 0, 0,
TRESPASS_PAGE, /* Page code */
0x02, /* Page length - 2 */
- 0x81, /* Trespass code + Honor reservation bit */
+ 0x81, /* Trespass code + Honor reservation
+ * bit */
0xff, /* Trespass target */
};
int res;
diff --git a/src/sg_format.c b/src/sg_format.c
index c26d1cac..2534aef6 100644
--- a/src/sg_format.c
+++ b/src/sg_format.c
@@ -196,7 +196,7 @@ scsi_format(int fd, int fmtpinfo, int cmplst, int pf_usage, int immed,
fmt_pl[1] |= 0x88; /* fov=1, ip=1 */
fmt_pl[off + 0] = 0x20; /* si=1 in init. pattern desc */
}
- if (longlist)
+ if (longlist)
fmt_pl[3] = (pie & 0xf); /* protection interval exponent */
need_hdr = (immed || cmplst || dcrt || si || (pf_usage > 0) ||
diff --git a/src/sg_get_config.c b/src/sg_get_config.c
index ef68de8b..d55cac52 100644
--- a/src/sg_get_config.c
+++ b/src/sg_get_config.c
@@ -868,7 +868,7 @@ decode_feature(int feature, unsigned char * ucp, int len)
num = ucp[5];
printf(" Profile numbers:\n");
for (k = 6; (num > 0) && (k < len); --num, k += 2) {
- printf(" %d\n",
+ printf(" %d\n",
((unsigned int)ucp[k] << 8) + ucp[k + 1]);
}
break;
diff --git a/src/sg_get_lba_status.c b/src/sg_get_lba_status.c
index 04b5a56a..584918e7 100644
--- a/src/sg_get_lba_status.c
+++ b/src/sg_get_lba_status.c
@@ -262,7 +262,7 @@ main(int argc, char * argv[])
}
if (rlen > maxlen)
rlen = maxlen;
-
+
if (do_brief > 1) {
if (rlen < 24) {
fprintf(stderr, "Need maxlen and response length to "
diff --git a/src/sg_inq.c b/src/sg_inq.c
index 231055d6..b62e3b4c 100644
--- a/src/sg_inq.c
+++ b/src/sg_inq.c
@@ -1796,8 +1796,8 @@ decode_b0_vpd(unsigned char * buff, int len, int do_hex, int pdt)
if (len > 19) { /* added in sbc3r09 */
u = (buff[16] << 24) | (buff[17] << 16) | (buff[18] << 8) |
buff[19];
- printf(" Maximum prefetch, xdread, xdwrite transfer length: %u "
- "blocks\n", u);
+ printf(" Maximum prefetch, xdread, xdwrite transfer length: "
+ "%u blocks\n", u);
}
if (len > 27) { /* added in sbc3r18 */
u = ((unsigned int)buff[20] << 24) | (buff[21] << 16) |
@@ -1910,15 +1910,18 @@ decode_b3_vpd(unsigned char * buff, int len, int do_hex, int pdt)
switch (pdt) {
case PDT_DISK: case PDT_WO: case PDT_OPTICAL:
if (len < 0xc0) {
- fprintf(stderr, "Referrals VPD page length too short=%d\n", len);
+ fprintf(stderr, "Referrals VPD page length too short=%d\n",
+ len);
return;
}
s = (buff[8] << 24) | (buff[9] << 16) | (buff[10] << 8) | buff[11];
- m = (buff[12] << 24) | (buff[13] << 16) | (buff[14] << 8) | buff[15];
+ m = (buff[12] << 24) | (buff[13] << 16) | (buff[14] << 8) |
+ buff[15];
if (0 == s)
printf(" Single user data segment\n");
else if (0 == m)
- printf(" Segment size specified by user data segment descriptor\n");
+ printf(" Segment size specified by user data segment "
+ "descriptor\n");
else
printf(" Segment size: %u, segment multiplier: %u\n", s, m);
break;
@@ -3400,7 +3403,8 @@ ata_command_interface(int device, char *data, int * atapi_flag, int verbose)
} else if (atapi_flag) {
*atapi_flag = 1;
if (verbose > 1)
- fprintf(stderr, "HDIO_DRIVE_CMD(ATA_IDENTIFY_DEVICE) succeeded\n");
+ fprintf(stderr, "HDIO_DRIVE_CMD(ATA_IDENTIFY_DEVICE) "
+ "succeeded\n");
}
} else { /* assume non-packet device */
buff[0] = ATA_IDENTIFY_DEVICE;
diff --git a/src/sg_inq_data.c b/src/sg_inq_data.c
index 5e8e9801..66f90e7a 100644
--- a/src/sg_inq_data.c
+++ b/src/sg_inq_data.c
@@ -475,4 +475,3 @@ struct sg_version_descriptor sg_version_descriptor_arr[] = {
{0xffff, NULL},
};
#endif
-
diff --git a/src/sg_logs.c b/src/sg_logs.c
index 8b61a0f2..405cf87d 100644
--- a/src/sg_logs.c
+++ b/src/sg_logs.c
@@ -25,7 +25,7 @@
#include "sg_lib.h"
#include "sg_cmds_basic.h"
-static char * version_str = "1.07 20120319"; /* spc4r35 + sbc3r30 */
+static char * version_str = "1.07 20121211"; /* spc4r35 + sbc3r30 */
#define MX_ALLOC_LEN (0xfffc)
#define SHORT_RESP_LEN 128
@@ -684,7 +684,9 @@ show_page_name(int pg_code, int subpg_code,
case START_STOP_LPAGE: printf("%sStart-stop cycle counter", b); break;
case APP_CLIENT_LPAGE: printf("%sApplication client", b); break;
case SELF_TEST_LPAGE: printf("%sSelf-test results", b); break;
- case PROTO_SPECIFIC_LPAGE: printf("%sProtocol specific port", b); break;
+ case PROTO_SPECIFIC_LPAGE:
+ printf("%sProtocol specific port", b);
+ break;
case STATS_LPAGE:
printf("%sGeneral statistics and performance", b);
break;
@@ -1624,11 +1626,11 @@ show_start_stop_page(unsigned char * resp, int len, int show_pcb, int verbose)
if (extra > 7) {
n = (ucp[4] << 24) | (ucp[5] << 16) | (ucp[6] << 8) | ucp[7];
if (0xffffffff == n)
- printf(" Specified load-unload count over device lifetime "
- "= -1");
+ printf(" Specified load-unload count over device "
+ "lifetime = -1");
else
- printf(" Specified load-unload count over device lifetime "
- "= %u", n);
+ printf(" Specified load-unload count over device "
+ "lifetime = %u", n);
}
break;
case 6:
@@ -3530,11 +3532,16 @@ show_seagate_cache_page(unsigned char * resp, int len, int show_pcb)
switch (pc) {
case 0: printf(" Blocks sent to initiator"); break;
case 1: printf(" Blocks received from initiator"); break;
- case 2: printf(" Blocks read from cache and sent to initiator"); break;
- case 3: printf(" Number of read and write commands whose size "
- "<= segment size"); break;
- case 4: printf(" Number of read and write commands whose size "
- "> segment size"); break;
+ case 2:
+ printf(" Blocks read from cache and sent to initiator");
+ break;
+ case 3:
+ printf(" Number of read and write commands whose size "
+ "<= segment size");
+ break;
+ case 4:
+ printf(" Number of read and write commands whose size "
+ "> segment size"); break;
default: printf(" Unknown Seagate parameter code = 0x%x", pc); break;
}
k = pl - 4;
diff --git a/src/sg_map.c b/src/sg_map.c
index d5f89106..f6c38a34 100644
--- a/src/sg_map.c
+++ b/src/sg_map.c
@@ -499,4 +499,3 @@ static void scan_dev_type(const char * leadin, int max_dev, int do_numeric,
fname);
}
}
-
diff --git a/src/sg_modes.c b/src/sg_modes.c
index a82a2d1a..26dd820d 100644
--- a/src/sg_modes.c
+++ b/src/sg_modes.c
@@ -118,8 +118,8 @@ usage()
"sense (10) cdb)\n"
" --maxlen=LEN|-m LEN max response length (allocation "
"length in cdb)\n"
- " (def: 0 -> 4096 or 252 (for MODE SENSE 6) "
- "bytes)\n"
+ " (def: 0 -> 4096 or 252 (for MODE "
+ "SENSE 6) bytes)\n"
" --page=PG|-p PG page code to fetch (def: 63)\n"
" --page=PG,SPG|-p PG,SPG\n"
" page code and subpage code to fetch "
diff --git a/src/sg_persist.c b/src/sg_persist.c
index 6f34f036..88d1e533 100644
--- a/src/sg_persist.c
+++ b/src/sg_persist.c
@@ -200,7 +200,7 @@ usage()
/* If num_tids==0 then only one TransportID is assumed with len bytes in
* it. If num_tids>0 then that many TransportIDs is assumed, each in an
* element that is MX_TID_LEN bytes long (and the 'len' argument is
- * ignored). */
+ * ignored). */
static void
decode_transport_id(const char * leadin, unsigned char * ucp, int len,
int num_tids)
@@ -210,7 +210,7 @@ decode_transport_id(const char * leadin, unsigned char * ucp, int len,
int bump;
if (num_tids > 0)
- len = num_tids * MX_TID_LEN;
+ len = num_tids * MX_TID_LEN;
for (k = 0, bump = MX_TID_LEN; k < len; k += bump, ucp += bump) {
if ((len < 24) || (0 != (len % 4)))
printf("%sTransport Id short or not multiple of 4 "
@@ -666,7 +666,7 @@ decode_sym_transportid(const char * lcp, unsigned char * tidp)
tidp[4 + j] = b | n;
++j;
} else
- b = n << 4;
+ b = n << 4;
}
return 1;
} else if ((0 == memcmp("spi,", lcp, 4)) ||
@@ -706,7 +706,7 @@ decode_sym_transportid(const char * lcp, unsigned char * tidp)
tidp[8 + j] = b | n;
++j;
} else
- b = n << 4;
+ b = n << 4;
}
return 1;
} else if ((0 == memcmp("sbp,", lcp, 4)) ||
@@ -732,7 +732,7 @@ decode_sym_transportid(const char * lcp, unsigned char * tidp)
tidp[8 + j] = b | n;
++j;
} else
- b = n << 4;
+ b = n << 4;
}
return 1;
} else if ((0 == memcmp("srp,", lcp, 4)) ||
@@ -758,7 +758,7 @@ decode_sym_transportid(const char * lcp, unsigned char * tidp)
tidp[8 + j] = b | n;
++j;
} else
- b = n << 4;
+ b = n << 4;
}
return 1;
} else if (0 == memcmp("iqn.", lcp, 4)) {
@@ -775,7 +775,7 @@ decode_sym_transportid(const char * lcp, unsigned char * tidp)
else if (0 != (alen % 4))
alen = ((alen / 4) + 1) * 4;
if (alen > 241) { /* sam5r02.pdf A.2 (Annex) */
- fprintf(stderr, "iSCSI name too long, alen=%d\n", alen);
+ fprintf(stderr, "iSCSI name too long, alen=%d\n", alen);
return 0;
}
tidp[3] = alen & 0xff;
diff --git a/src/sg_raw.c b/src/sg_raw.c
index b9d223eb..9f78146d 100644
--- a/src/sg_raw.c
+++ b/src/sg_raw.c
@@ -438,7 +438,7 @@ main(int argc, char *argv[])
goto done;
}
set_scsi_pt_data_out(ptvp, dxfer_buffer_out, opts.dataout_len);
- }
+ }
if (opts.do_datain) {
dxfer_buffer_in = my_memalign(opts.datain_len, &wrkBuf);
if (dxfer_buffer_in == NULL) {
diff --git a/src/sg_read.c b/src/sg_read.c
index b18bfa33..d5e5a8bd 100644
--- a/src/sg_read.c
+++ b/src/sg_read.c
@@ -1,3 +1,23 @@
+/* A utility program for the Linux OS SCSI generic ("sg") device driver.
+* Copyright (C) 2001 - 2012 D. Gilbert
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2, or (at your option)
+* any later version.
+
+ This program reads data from the given SCSI device (typically a disk
+ or cdrom) and discards that data. Its primary goal is to time
+ multiple reads all starting from the same logical address. Its interface
+ is a subset of another member of this package: sg_dd which is a
+ "dd" variant. The input file can be a scsi generic device, a block device,
+ a raw device or a seekable file. Streams such as stdin are not acceptable.
+ The block size ('bs') is assumed to be 512 if not given.
+
+ This version should compile with Linux sg drivers with version numbers
+ >= 30000 . For mmap-ed IO the sg version number >= 30122 .
+
+*/
+
#define _XOPEN_SOURCE 500
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
@@ -27,27 +47,8 @@
#include "sg_lib.h"
#include "sg_io_linux.h"
-/* A utility program for the Linux OS SCSI generic ("sg") device driver.
-* Copyright (C) 2001 - 2007 D. Gilbert
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, or (at your option)
-* any later version.
-
- This program reads data from the given SCSI device (typically a disk
- or cdrom) and discards that data. Its primary goal is to time
- multiple reads all starting from the same logical address. Its interface
- is a subset of another member of this package: sg_dd which is a
- "dd" variant. The input file can be a scsi generic device, a block device,
- a raw device or a seekable file. Streams such as stdin are not acceptable.
- The block size ('bs') is assumed to be 512 if not given.
-
- This version should compile with Linux sg drivers with version numbers
- >= 30000 . For mmap-ed IO the sg version number >= 30122 .
-
-*/
-static const char * version_str = "1.18 20071226";
+static const char * version_str = "1.19 20121211";
#define DEF_BLOCK_SIZE 512
#define DEF_BLOCKS_PER_TRANSFER 128
@@ -189,7 +190,8 @@ static void usage()
" no_dxfer 1->DMA to kernel buffers only, not user space, "
"0->normal(def)\n"
" odir 1->open block device O_DIRECT, 0->don't (def)\n"
- " skip each transfer starts at this logical address (def=0)\n"
+ " skip each transfer starts at this logical address "
+ "(def=0)\n"
" time 0->do nothing(def), 1->time from 1st cmd, 2->time "
"from 2nd, ...\n"
" verbose increase level of verbosity (def: 0)\n"
@@ -316,7 +318,8 @@ static int sg_bread(int sg_fd, unsigned char * buff, int blocks,
if (blocks > 0) {
io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
io_hdr.dxfer_len = bs * blocks;
- if (! do_mmap) /* not required: shows dxferp unused during mmap-ed IO */
+ /* next: shows dxferp unused during mmap-ed IO */
+ if (! do_mmap)
io_hdr.dxferp = buff;
if (diop && *diop)
io_hdr.flags |= SG_FLAG_DIRECT_IO;
diff --git a/src/sg_read_buffer.c b/src/sg_read_buffer.c
index 731ed336..5190ae8b 100644
--- a/src/sg_read_buffer.c
+++ b/src/sg_read_buffer.c
@@ -25,7 +25,7 @@
* This utility issues the SCSI READ BUFFER command to the given device.
*/
-static char * version_str = "1.08 20120224";
+static char * version_str = "1.08 20121211";
static struct option long_options[] = {
@@ -305,8 +305,8 @@ main(int argc, char * argv[])
switch (rb_mode) {
case MODE_DESCRIPTOR:
k = (resp[1] << 16) | (resp[2] << 8) | resp[3];
- printf("OFFSET BOUNDARY: %d, Buffer offset alignment: %d-byte\n",
- resp[0], (1 << resp[0]));
+ printf("OFFSET BOUNDARY: %d, Buffer offset alignment: "
+ "%d-byte\n", resp[0], (1 << resp[0]));
printf("BUFFER CAPACITY: %d (0x%x)\n", k, k);
break;
case MODE_ECHO_BDESC:
diff --git a/src/sg_sanitize.c b/src/sg_sanitize.c
index 9b5cd381..07f5766a 100644
--- a/src/sg_sanitize.c
+++ b/src/sg_sanitize.c
@@ -26,7 +26,7 @@
#include "sg_cmds_basic.h"
#include "sg_cmds_extra.h"
-static char * version_str = "0.91 20120222";
+static char * version_str = "0.91 20121211";
/* Not all environments support the Unix sleep() */
#if defined(MSC_VER) || defined(__MINGW32__)
@@ -98,12 +98,12 @@ static void
usage()
{
fprintf(stderr, "Usage: "
- "sg_sanitize [--ause] [--block] [--count=OC] [--crypto] [--early] "
- "[--fail] [--help]\n"
- " [--invert] [--ipl=LEN] [--overwrite] "
- "[--pattern=PF]\n"
- " [--quick] [--test=TE] [--verbose] [--version] [--wait] "
- "DEVICE\n"
+ "sg_sanitize [--ause] [--block] [--count=OC] [--crypto] [--early]\n"
+ " [--fail] [--help] [--invert] [--ipl=LEN] "
+ "[--overwrite]\n"
+ " [--pattern=PF] [--quick] [--test=TE] "
+ "[--verbose]\n"
+ " [--version] [--wait] DEVICE\n"
" where:\n"
" --ause|-A set AUSE bit in cdb\n"
" --block|-B do BLOCK ERASE sanitize\n"
@@ -389,7 +389,7 @@ main(int argc, char * argv[])
}
}
-
+
sg_fd = sg_cmds_open_device(device_name, 0 /* rw */, vb);
if (sg_fd < 0) {
fprintf(stderr, ME "open error: %s: %s\n", device_name,
diff --git a/src/sg_scan.c.linux b/src/sg_scan.c.linux
index 64c36854..cc8846d1 100644
--- a/src/sg_scan.c.linux
+++ b/src/sg_scan.c.linux
@@ -1,3 +1,28 @@
+/* A utility program originally written for the Linux OS SCSI subsystem.
+ * Copyright (C) 1999 - 2019 D. Gilbert
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program scans the "sg" device space (ie actual + simulated SCSI
+ * generic devices). Optionally sg_scan can be given other device names
+ * to scan (in place of the sg devices).
+ * Options: -a alpha scan: scan /dev/sga,b,c, ....
+ * -i do SCSI inquiry on device (implies -w)
+ * -n numeric scan: scan /dev/sg0,1,2, ....
+ * -V output version string and exit
+ * -w open writable (new driver opens readable unless -i)
+ * -x extra information output
+ *
+ * By default this program will look for /dev/sg0 first (i.e. numeric scan)
+ *
+ * Note: This program is written to work under both the original and
+ * the new sg driver.
+ *
+ * F. Jansen - modification to extend beyond 26 sg devices.
+ */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -24,32 +49,8 @@
#include "sg_lib.h"
#include "sg_io_linux.h"
-/* A utility program originally written for the Linux OS SCSI subsystem.
- * Copyright (C) 1999 - 2009 D. Gilbert
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program scans the "sg" device space (ie actual + simulated SCSI
- * generic devices). Optionally sg_scan can be given other device names
- * to scan (in place of the sg devices).
- * Options: -a alpha scan: scan /dev/sga,b,c, ....
- * -i do SCSI inquiry on device (implies -w)
- * -n numeric scan: scan /dev/sg0,1,2, ....
- * -V output version string and exit
- * -w open writable (new driver opens readable unless -i)
- * -x extra information output
- *
- * By default this program will look for /dev/sg0 first (i.e. numeric scan)
- *
- * Note: This program is written to work under both the original and
- * the new sg driver.
- *
- * F. Jansen - modification to extend beyond 26 sg devices.
- */
-static char * version_str = "4.09 20070714";
+static char * version_str = "4.10 20121211";
#define ME "sg_scan: "
@@ -192,7 +193,7 @@ int main(int argc, char * argv[])
const char * cp;
struct stat a_stat;
- if (NULL == (gen_index_arr =
+ if (NULL == (gen_index_arr =
(int *)calloc(max_file_args + 1, sizeof(int)))) {
printf(ME "Out of memory\n");
return SG_LIB_CAT_OTHER;
@@ -292,7 +293,8 @@ int main(int argc, char * argv[])
sg_fd = open(file_namep, flags);
if (sg_fd < 0) {
if (EBUSY == errno) {
- printf("%s: device busy (O_EXCL lock), skipping\n", file_namep);
+ printf("%s: device busy (O_EXCL lock), skipping\n",
+ file_namep);
continue;
}
else if ((ENODEV == errno) || (ENOENT == errno) ||
diff --git a/src/sg_scan.c.win32 b/src/sg_scan.c.win32
index ef5554ad..18943ba2 100644
--- a/src/sg_scan.c.win32
+++ b/src/sg_scan.c.win32
@@ -1,7 +1,3 @@
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
/*
* Copyright (c) 2006-2012 Douglas Gilbert.
* All rights reserved.
@@ -15,6 +11,10 @@
* an optional scsi adapter scan.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
@@ -28,7 +28,7 @@
#define _WIN32_WINNT 0x0602
#include "sg_pt_win32.h"
-static char * version_str = "1.09 (win32) 20121026";
+static char * version_str = "1.10 (win32) 20121211";
#define MAX_SCSI_ELEMS 1024
#define MAX_ADAPTER_NUM 64
@@ -261,7 +261,8 @@ query_dev_property(HANDLE hdevice,
{
DWORD num_out, err;
char b[256];
- STORAGE_PROPERTY_QUERY query = {StorageDeviceProperty, PropertyStandardQuery, {0} };
+ STORAGE_PROPERTY_QUERY query = {StorageDeviceProperty,
+ PropertyStandardQuery, {0} };
memset(data, 0, sizeof(*data));
if (! DeviceIoControl(hdevice, IOCTL_STORAGE_QUERY_PROPERTY,
@@ -276,8 +277,8 @@ query_dev_property(HANDLE hdevice,
}
if (verbose > 3)
- fprintf(stderr, " IOCTL_STORAGE_QUERY_PROPERTY(DevProp) num_out=%ld\n",
- num_out);
+ fprintf(stderr, " IOCTL_STORAGE_QUERY_PROPERTY(DevProp) "
+ "num_out=%ld\n", num_out);
return 0;
}
@@ -356,8 +357,8 @@ enum_scsi_adapters(void)
if (fh != INVALID_HANDLE_VALUE) {
hole_count = 0;
success = DeviceIoControl(fh, IOCTL_SCSI_GET_INQUIRY_DATA,
- NULL, 0, inqDataBuff, sizeof(inqDataBuff),
- &dummy, FALSE);
+ NULL, 0, inqDataBuff,
+ sizeof(inqDataBuff), &dummy, FALSE);
if (success) {
PSCSI_BUS_DATA pbd;
PSCSI_INQUIRY_DATA pid;
@@ -378,8 +379,10 @@ enum_scsi_adapters(void)
pid->PathId, pid->TargetId, pid->Lun);
printf("%-15s", b);
snprintf(b, sizeof(b) - 1, "claimed=%d pdt=%xh %s ",
- pid->DeviceClaimed, pid->InquiryData[0] % 0x3f,
- ((0 == pid->InquiryData[4]) ? "dubious" : ""));
+ pid->DeviceClaimed,
+ pid->InquiryData[0] % 0x3f,
+ ((0 == pid->InquiryData[4]) ? "dubious" :
+ ""));
printf("%-26s", b);
printf("%.8s %.16s %.4s\n", pid->InquiryData + 8,
pid->InquiryData + 16, pid->InquiryData + 32);
@@ -425,12 +428,14 @@ enum_volumes(char letter)
OPEN_EXISTING, 0, NULL);
if (fh != INVALID_HANDLE_VALUE) {
if (query_dev_property(fh, &tmp_se.qp_descriptor) < 0)
- fprintf(stderr, "%s: query_dev_property failed\n", __FUNCTION__ );
+ fprintf(stderr, "%s: query_dev_property failed\n",
+ __FUNCTION__ );
else
tmp_se.qp_descriptor_valid = 1;
if (query_dev_uid(fh, &tmp_se.qp_uid) < 0) {
if (verbose > 2)
- fprintf(stderr, "%s: query_dev_uid failed\n", __FUNCTION__ );
+ fprintf(stderr, "%s: query_dev_uid failed\n",
+ __FUNCTION__ );
} else
tmp_se.qp_uid_valid = 1;
if (('\0' == letter) || (letter == tmp_se.name[0]))
@@ -464,12 +469,14 @@ enum_pds(void)
OPEN_EXISTING, 0, NULL);
if (fh != INVALID_HANDLE_VALUE) {
if (query_dev_property(fh, &tmp_se.qp_descriptor) < 0)
- fprintf(stderr, "%s: query_dev_property failed\n", __FUNCTION__ );
+ fprintf(stderr, "%s: query_dev_property failed\n",
+ __FUNCTION__ );
else
tmp_se.qp_descriptor_valid = 1;
if (query_dev_uid(fh, &tmp_se.qp_uid) < 0) {
if (verbose > 2)
- fprintf(stderr, "%s: query_dev_uid failed\n", __FUNCTION__ );
+ fprintf(stderr, "%s: query_dev_uid failed\n",
+ __FUNCTION__ );
} else
tmp_se.qp_uid_valid = 1;
hole_count = 0;
@@ -510,12 +517,14 @@ enum_cdroms(void)
OPEN_EXISTING, 0, NULL);
if (fh != INVALID_HANDLE_VALUE) {
if (query_dev_property(fh, &tmp_se.qp_descriptor) < 0)
- fprintf(stderr, "%s: query_dev_property failed\n", __FUNCTION__ );
+ fprintf(stderr, "%s: query_dev_property failed\n",
+ __FUNCTION__ );
else
tmp_se.qp_descriptor_valid = 1;
if (query_dev_uid(fh, &tmp_se.qp_uid) < 0) {
if (verbose > 2)
- fprintf(stderr, "%s: query_dev_uid failed\n", __FUNCTION__ );
+ fprintf(stderr, "%s: query_dev_uid failed\n",
+ __FUNCTION__ );
} else
tmp_se.qp_uid_valid = 1;
hole_count = 0;
@@ -556,12 +565,14 @@ enum_tapes(void)
OPEN_EXISTING, 0, NULL);
if (fh != INVALID_HANDLE_VALUE) {
if (query_dev_property(fh, &tmp_se.qp_descriptor) < 0)
- fprintf(stderr, "%s: query_dev_property failed\n", __FUNCTION__ );
+ fprintf(stderr, "%s: query_dev_property failed\n",
+ __FUNCTION__ );
else
tmp_se.qp_descriptor_valid = 1;
if (query_dev_uid(fh, &tmp_se.qp_uid) < 0) {
if (verbose > 2)
- fprintf(stderr, "%s: query_dev_uid failed\n", __FUNCTION__ );
+ fprintf(stderr, "%s: query_dev_uid failed\n",
+ __FUNCTION__ );
} else
tmp_se.qp_uid_valid = 1;
hole_count = 0;
@@ -620,7 +631,8 @@ sg_do_wscan(char letter, int show_bt, int scsi_scan)
printf("[%4s+] ", sp->volume_letters);
if (sp->qp_descriptor_valid) {
if (show_bt)
- printf("<%s> ", get_bus_type(sp->qp_descriptor.desc.BusType));
+ printf("<%s> ",
+ get_bus_type(sp->qp_descriptor.desc.BusType));
j = sp->qp_descriptor.desc.VendorIdOffset;
if (j > 0)
printf("%s ", sp->qp_descriptor.raw + j);
diff --git a/src/sg_ses.c b/src/sg_ses.c
index 0af842ad..6f916f9f 100644
--- a/src/sg_ses.c
+++ b/src/sg_ses.c
@@ -27,7 +27,7 @@
* commands tailored for SES (enclosure) devices.
*/
-static char * version_str = "1.70 20121124"; /* ses3r05 */
+static char * version_str = "1.70 20121211"; /* ses3r05 */
#define MX_ALLOC_LEN ((64 * 1024) - 1)
#define MX_ELEM_HDR 1024
@@ -64,7 +64,7 @@ static char * version_str = "1.70 20121124"; /* ses3r05 */
#define POWER_SUPPLY_ETC 0x2
#define COOLING_ETC 0x3
#define TEMPERATURE_ETC 0x4
-#define DOOR_ETC 0x5 /* prior to ses3r05 was DOOR_LOCK_ETC */
+#define DOOR_ETC 0x5 /* prior to ses3r05 was DOOR_LOCK_ETC */
#define AUD_ALARM_ETC 0x6
#define ESC_ELECTRONICS_ETC 0x7
#define SCC_CELECTR_ETC 0x8
@@ -324,8 +324,8 @@ static struct element_type_t element_type_arr[] = {
{POWER_SUPPLY_ETC, "ps", "Power supply"},
{COOLING_ETC, "coo", "Cooling"},
{TEMPERATURE_ETC, "ts", "Temperature sensor"},
- {DOOR_ETC, "do", "Door"}, /* prior to ses3r05 was 'dl' (for Door Lock)
- but the "Lock" has been dropped */
+ {DOOR_ETC, "do", "Door"}, /* prior to ses3r05 was 'dl' (for Door Lock)
+ but the "Lock" has been dropped */
{AUD_ALARM_ETC, "aa", "Audible alarm"},
{ESC_ELECTRONICS_ETC, "esc", "Enclosure services controller electronics"},
{SCC_CELECTR_ETC, "sce", "SCC controller electronics"},
@@ -963,7 +963,7 @@ find_out_diag_page_desc(int page_num)
}
return NULL;
}
-
+
/* Return of 0 -> success, SG_LIB_CAT_INVALID_OP -> Send diagnostic not
* supported, SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb,
* SG_LIB_CAT_NOT_READY, SG_LIB_CAT_UNIT_ATTENTION,
@@ -1557,7 +1557,7 @@ enc_status_helper(const char * pad, const unsigned char * statp, int etype,
else
printf("%sTemperature: <reserved>\n", pad);
break;
- case DOOR_ETC: /* OPEN field added in ses3r05 */
+ case DOOR_ETC: /* OPEN field added in ses3r05 */
if ((! filter) || ((0xc0 & statp[1]) || (0x1 & statp[3])))
printf("%sIdent=%d, Fail=%d, Open=%d, Unlock=%d\n", pad,
!!(statp[1] & 0x80), !!(statp[1] & 0x40),
@@ -3100,7 +3100,7 @@ try_again:
}
}
if (0 == got1) {
- if (op->ind_given)
+ if (op->ind_given)
printf(" >>> no match on --index=%d,%d\n", op->ind_th,
op->ind_indiv);
if (op->desc_name)
@@ -3178,7 +3178,7 @@ strcase_eq(const char * s1p, const char * s2p)
static int
is_acronym_in_status_ctl(const struct tuple_acronym_val * tavp)
-{
+{
const struct acronym2tuple * a2tp;
for (a2tp = ecs_a2t_arr; a2tp->acron; ++ a2tp) {
@@ -3190,7 +3190,7 @@ is_acronym_in_status_ctl(const struct tuple_acronym_val * tavp)
static int
is_acronym_in_threshold(const struct tuple_acronym_val * tavp)
-{
+{
const struct acronym2tuple * a2tp;
for (a2tp = th_a2t_arr; a2tp->acron; ++ a2tp) {
@@ -3202,7 +3202,7 @@ is_acronym_in_threshold(const struct tuple_acronym_val * tavp)
static int
is_acronym_in_additional(const struct tuple_acronym_val * tavp)
-{
+{
const struct acronym2tuple * a2tp;
for (a2tp = ae_sas_a2t_arr; a2tp->acron; ++ a2tp) {
@@ -3243,7 +3243,8 @@ cgs_enc_ctl_stat(int sg_fd, const struct join_row_t * jrp,
return -2;
}
if (op->verbose > 1)
- fprintf(stderr, " s_byte=%d, s_bit=%d, n_bits=%d\n", s_byte, s_bit, n_bits);
+ fprintf(stderr, " s_byte=%d, s_bit=%d, n_bits=%d\n", s_byte, s_bit,
+ n_bits);
if (op->get_str) {
ui = get_big_endian(jrp->enc_statp + s_byte, s_bit, n_bits);
if (op->do_hex)
@@ -3382,7 +3383,7 @@ ses_cgs(int sg_fd, const struct tuple_acronym_val * tavp,
char b[64];
found = 0;
- if (NULL == tavp->acron) {
+ if (NULL == tavp->acron) {
if (! op->page_code_given)
op->page_code = DPC_ENC_CONTROL;
++found;
diff --git a/src/sg_stpg.c b/src/sg_stpg.c
index 4ff3da6d..17b0b02c 100644
--- a/src/sg_stpg.c
+++ b/src/sg_stpg.c
@@ -24,7 +24,7 @@
* to the given SCSI device.
*/
-static char * version_str = "1.5 20121019";
+static char * version_str = "1.5 20121211";
#define TGT_GRP_BUFF_LEN 1024
#define MX_ALLOC_LEN (0xc000 + 0x80)
@@ -565,15 +565,16 @@ main(int argc, char * argv[])
return SG_LIB_CAT_MALFORMED;
}
if (report_len > MX_ALLOC_LEN) {
- fprintf(stderr, "response length too long: %d > %d\n", report_len,
- MX_ALLOC_LEN);
+ fprintf(stderr, "response length too long: %d > %d\n",
+ report_len, MX_ALLOC_LEN);
return SG_LIB_CAT_MALFORMED;
} else if (report_len > DEF_VPD_DEVICE_ID_LEN) {
if (sg_ll_inquiry(sg_fd, 0, 1, VPD_DEVICE_ID, rsp_buff,
report_len, 1, verbose))
return SG_LIB_CAT_OTHER;
}
- decode_target_port(rsp_buff + 4, report_len - 4, &relport, &portgroup);
+ decode_target_port(rsp_buff + 4, report_len - 4, &relport,
+ &portgroup);
printf("Device is at port Group 0x%02x, relative port 0x%02x\n",
portgroup, relport);
}
@@ -629,7 +630,8 @@ main(int argc, char * argv[])
off = 8 + tgt_port_count * 4;
}
} else if (SG_LIB_CAT_INVALID_OP == res)
- fprintf(stderr, "Report Target Port Groups command not supported\n");
+ fprintf(stderr, "Report Target Port Groups command not "
+ "supported\n");
else if (SG_LIB_CAT_ILLEGAL_REQ == res)
fprintf(stderr, "bad field in Report Target Port Groups cdb "
"including unsupported service action\n");
diff --git a/src/sg_vpd.c b/src/sg_vpd.c
index d79a52f7..b2f9a306 100644
--- a/src/sg_vpd.c
+++ b/src/sg_vpd.c
@@ -30,7 +30,7 @@
*/
-static char * version_str = "0.64 20121204"; /* spc4r36 + sbc3r34 */
+static char * version_str = "0.64 20121211"; /* spc4r36 + sbc3r34 */
extern void svpd_enumerate_vendor(void);
extern int svpd_decode_vendor(int sg_fd, int num_vpd, int subvalue,
@@ -1296,7 +1296,7 @@ decode_x_inq_vpd(unsigned char * b, int len, int do_hex, int do_long,
printf(" POA_SUP=%d\n", !!(b[12] & 0x80)); /* spc4r32 */
printf(" HRA_SUP=%d\n", !!(b[12] & 0x40)); /* spc4r32 */
printf(" VSA_SUP=%d\n", !!(b[12] & 0x20)); /* spc4r32 */
- printf(" Maximum supported sense data length=%d\n",
+ printf(" Maximum supported sense data length=%d\n",
b[13]); /* spc4r34 */
return;
}
@@ -2361,7 +2361,8 @@ svpd_decode_t10(int sg_fd, int num_vpd, int subvalue, int maxlen, int do_hex,
printf(" [PQual=%d Peripheral device type: %s]\n",
(rsp_buff[0] & 0xe0) >> 5,
sg_get_pdt_str(pdt, sizeof(buff), buff));
- decode_scsi_ports_vpd(rsp_buff, len, do_hex, do_long, do_quiet);
+ decode_scsi_ports_vpd(rsp_buff, len, do_hex, do_long,
+ do_quiet);
}
return 0;
}
@@ -2826,7 +2827,8 @@ svpd_decode_t10(int sg_fd, int num_vpd, int subvalue, int maxlen, int do_hex,
printf("Referrals VPD page (SBC):\n");
break;
case PDT_TAPE: case PDT_MCHANGER:
- printf("Automation device serial number VPD page (SSC):\n");
+ printf("Automation device serial number VPD page "
+ "(SSC):\n");
break;
default:
printf("VPD page=0x%x, pdt=0x%x:\n", 0xb3, pdt);
diff --git a/src/sg_vpd_vendor.c b/src/sg_vpd_vendor.c
index 634ff633..675e175e 100644
--- a/src/sg_vpd_vendor.c
+++ b/src/sg_vpd_vendor.c
@@ -216,17 +216,18 @@ decode_vpd_c0_hp3par(unsigned char * buff, int len)
printf(" Allocation unit: %d\n", (buff[8] << 24) + (buff[9] << 16) +
(buff[10] << 8) + buff[11]);
- printf(" Data pool size: %" PRIu64 "\n", (((uint64_t) buff[12]) << 56) +
- (((uint64_t) buff[13]) << 48) + (((uint64_t) buff[14]) << 40) +
- (((uint64_t) buff[15]) << 32) + ((uint64_t) buff[16] << 24) +
- (buff[17] << 16) + (buff[18] << 8) + buff[19]);
-
- printf(" Space allocated: %" PRIu64 "\n", ((uint64_t) buff[20] << 56) +
- ((uint64_t) buff[21] << 48) + ((uint64_t) buff[22] << 40) +
- ((uint64_t) buff[23] << 32) + ((uint64_t) buff[24] << 24) +
- (buff[25] << 16) + (buff[26] << 8) + buff[27]);
+ printf(" Data pool size: %" PRIu64 "\n",
+ (((uint64_t)buff[12]) << 56) + (((uint64_t)buff[13]) << 48) +
+ (((uint64_t)buff[14]) << 40) + (((uint64_t)buff[15]) << 32) +
+ (((uint64_t)buff[16]) << 24) + (buff[17] << 16) +
+ (buff[18] << 8) + buff[19]);
+
+ printf(" Space allocated: %" PRIu64 "\n",
+ (((uint64_t)buff[20]) << 56) + (((uint64_t)buff[21]) << 48) +
+ (((uint64_t)buff[22]) << 40) + (((uint64_t)buff[23]) << 32) +
+ (((uint64_t)buff[24]) << 24) + (buff[25] << 16) +
+ (buff[26] << 8) + buff[27]);
}
-
return;
}
diff --git a/src/sg_write_same.c b/src/sg_write_same.c
index 783465ac..4d728888 100644
--- a/src/sg_write_same.c
+++ b/src/sg_write_same.c
@@ -472,7 +472,7 @@ main(int argc, char * argv[])
opts.xfer_len = (int)a_stat.st_size;
}
}
-
+
sg_fd = sg_cmds_open_device(device_name, 0 /* rw */, vb);
if (sg_fd < 0) {
fprintf(stderr, ME "open error: %s: %s\n", device_name,
diff --git a/src/sg_xcopy.c b/src/sg_xcopy.c
index 08f7cee8..bb76e14e 100644
--- a/src/sg_xcopy.c
+++ b/src/sg_xcopy.c
@@ -625,16 +625,18 @@ scsi_operating_parameter(struct xcopy_fp_t *xfp, int is_target)
int res;
unsigned char rcBuff[256];
unsigned int rcBuffLen = 256, len, n, td_list = 0;
- unsigned long num, max_target_num, max_segment_num;
- unsigned long max_segment_len, max_desc_len, max_inline_data, held_data_limit;
+ unsigned long num, max_target_num, max_segment_num, max_segment_len;
+ unsigned long max_desc_len, max_inline_data, held_data_limit;
int verb, valid = 0;
verb = (verbose ? verbose - 1: 0);
- res = sg_ll_receive_copy_results(xfp->sg_fd, 0x03, 0, rcBuff, rcBuffLen, 0, verb);
+ res = sg_ll_receive_copy_results(xfp->sg_fd, 0x03, 0, rcBuff, rcBuffLen,
+ 0, verb);
if (0 != res)
return -res;
- len = (rcBuff[0] << 24) | (rcBuff[1] << 16) | (rcBuff[2] << 8) | rcBuff[3];
+ len = (rcBuff[0] << 24) | (rcBuff[1] << 16) | (rcBuff[2] << 8) |
+ rcBuff[3];
if (len > rcBuffLen) {
fprintf(stderr, " <<report too long for internal buffer,"
" output truncated\n");
@@ -645,11 +647,13 @@ scsi_operating_parameter(struct xcopy_fp_t *xfp, int is_target)
}
max_target_num = rcBuff[8] << 8 | rcBuff[9];
max_segment_num = rcBuff[10] << 8 | rcBuff[11];
- max_desc_len = rcBuff[12] << 24 | rcBuff[13] << 16 | rcBuff[14] << 8 | rcBuff[15];
+ max_desc_len = rcBuff[12] << 24 | rcBuff[13] << 16 | rcBuff[14] << 8 |
+ rcBuff[15];
max_segment_len = rcBuff[16] << 24 | rcBuff[17] << 16 |
rcBuff[18] << 8 | rcBuff[19];
xfp->max_bytes = max_segment_len;
- max_inline_data = rcBuff[20] << 24 | rcBuff[21] << 16 | rcBuff[22] << 8 | rcBuff[23];
+ max_inline_data = rcBuff[20] << 24 | rcBuff[21] << 16 | rcBuff[22] << 8 |
+ rcBuff[23];
if (verbose) {
printf(" >> Receive copy results (report operating parameters):\n");
printf(" Maximum target descriptor count: %lu\n", max_target_num);
@@ -669,7 +673,8 @@ scsi_operating_parameter(struct xcopy_fp_t *xfp, int is_target)
if (verbose) {
printf(" Held data limit: %lu (usage: %d)\n",
held_data_limit, list_id_usage);
- num = rcBuff[28] << 24 | rcBuff[29] << 16 | rcBuff[30] << 8 | rcBuff[31];
+ num = rcBuff[28] << 24 | rcBuff[29] << 16 | rcBuff[30] << 8 |
+ rcBuff[31];
printf(" Maximum stream device transfer size: %lu\n", num);
printf(" Maximum concurrent copies: %u\n", rcBuff[36]);
printf(" Data segment granularity: %u bytes\n", 1 << rcBuff[37]);
@@ -752,7 +757,8 @@ scsi_operating_parameter(struct xcopy_fp_t *xfp, int is_target)
if (is_target && (xfp->sg_type & FT_ST))
valid++;
if (verbose)
- printf(" Copy block device with offset to stream device\n");
+ printf(" Copy block device with offset to stream "
+ "device\n");
break;
case 0x09: /* copy stream device to block device with offset */
if (!is_target && (xfp->sg_type & FT_ST))
@@ -760,15 +766,18 @@ scsi_operating_parameter(struct xcopy_fp_t *xfp, int is_target)
if (is_target && (xfp->sg_type & FT_BLOCK))
valid++;
if (verbose)
- printf(" Copy stream device to block device with offset\n");
+ printf(" Copy stream device to block device with "
+ "offset\n");
break;
- case 0x0a: /* copy block device with offset to block device with offset */
+ case 0x0a: /* copy block device with offset to block device with
+ * offset */
if (!is_target && (xfp->sg_type & FT_BLOCK))
valid++;
if (is_target && (xfp->sg_type & FT_BLOCK))
valid++;
if (verbose)
- printf(" Copy block device with offset to block device with offset\n");
+ printf(" Copy block device with offset to block "
+ "device with offset\n");
break;
case 0x0b: /* copy block device to stream device and hold data */
if (!is_target && (xfp->sg_type & FT_BLOCK))
@@ -776,7 +785,8 @@ scsi_operating_parameter(struct xcopy_fp_t *xfp, int is_target)
if (is_target && (xfp->sg_type & FT_ST))
valid++;
if (verbose)
- printf(" Copy block device to stream device and hold data\n");
+ printf(" Copy block device to stream device and hold "
+ "data\n");
break;
case 0x0c: /* copy stream device to block device and hold data */
if (!is_target && (xfp->sg_type & FT_ST))
@@ -784,7 +794,8 @@ scsi_operating_parameter(struct xcopy_fp_t *xfp, int is_target)
if (is_target && (xfp->sg_type & FT_BLOCK))
valid++;
if (verbose)
- printf(" Copy stream device to block device and hold data\n");
+ printf(" Copy stream device to block device and hold "
+ "data\n");
break;
case 0x0d: /* copy block device to block device and hold data */
if (!is_target && (xfp->sg_type & FT_BLOCK))
@@ -792,7 +803,8 @@ scsi_operating_parameter(struct xcopy_fp_t *xfp, int is_target)
if (is_target && (xfp->sg_type & FT_BLOCK))
valid++;
if (verbose)
- printf(" Copy block device to block device and hold data\n");
+ printf(" Copy block device to block device and hold "
+ "data\n");
break;
case 0x0e: /* copy stream device to stream device and hold data */
if (!is_target && (xfp->sg_type & FT_ST))
@@ -800,7 +812,8 @@ scsi_operating_parameter(struct xcopy_fp_t *xfp, int is_target)
if (is_target && (xfp->sg_type & FT_ST))
valid++;
if (verbose)
- printf(" Copy block device to block device and hold data\n");
+ printf(" Copy block device to block device and hold "
+ "data\n");
break;
case 0x0f: /* read from stream device and hold data */
if (!is_target && (xfp->sg_type & FT_ST))
@@ -822,7 +835,8 @@ scsi_operating_parameter(struct xcopy_fp_t *xfp, int is_target)
break;
case 0xe2: /* FC N_Port_ID with N_Port_Name checking */
if (verbose)
- printf(" FC N_Port_ID with N_Port_Name target descriptor\n");
+ printf(" FC N_Port_ID with N_Port_Name target "
+ "descriptor\n");
td_list |= TD_FC_WWPN_AND_PORT;
break;
case 0xe3: /* Parallel Interface T_L */
@@ -1086,12 +1100,14 @@ desc_from_vpd_id(int sg_fd, unsigned char *desc, int desc_len,
dStrHex((const char *)rcBuff, len, 1);
}
- while ((u = sg_vpd_dev_id_iter(rcBuff + 4, len - 4, &off, 0, -1, -1)) == 0) {
+ while ((u = sg_vpd_dev_id_iter(rcBuff + 4, len - 4, &off, 0, -1, -1)) ==
+ 0) {
ucp = rcBuff + 4 + off;
i_len = ucp[3];
if (((unsigned int)off + i_len + 4) > len) {
fprintf(stderr, " VPD page error: designator length %d longer "
- "than\n remaining response length=%d\n", i_len, (len - off));
+ "than\n remaining response length=%d\n", i_len,
+ (len - off));
return SG_LIB_CAT_MALFORMED;
}
assoc = ((ucp[1] >> 4) & 0x3);
@@ -1514,8 +1530,9 @@ main(int argc, char * argv[])
}
#ifdef SG_DEBUG
- fprintf(stderr, ME "if=%s skip=%"PRId64" of=%s seek=%"PRId64" count=%"PRId64"\n",
- ifp.fname, skip, ofp.fname, seek, dd_count);
+ fprintf(stderr, ME "if=%s skip=%" PRId64 " of=%s seek=%" PRId64
+ " count=%" PRId64 "\n", ifp.fname, skip, ofp.fname, seek,
+ dd_count);
#endif
install_handler(SIGINT, interrupt_handler);
install_handler(SIGQUIT, interrupt_handler);
diff --git a/src/sginfo.c b/src/sginfo.c
index 7d284af7..4baae510 100644
--- a/src/sginfo.c
+++ b/src/sginfo.c
@@ -122,7 +122,7 @@
#define _GNU_SOURCE
#endif
-static const char * version_str = "2.30 [20120224]";
+static const char * version_str = "2.30 [20121211]";
#include <stdio.h>
#include <string.h>
@@ -387,7 +387,8 @@ struct scsi_cmnd_io
/* Returns 0 -> ok, 1 -> general error, 2 -> unknown opcode,
3 -> unsupported field in cdb, 4 -> unsupported param in data-in */
-static int do_scsi_io(struct scsi_cmnd_io * sio)
+static int
+do_scsi_io(struct scsi_cmnd_io * sio)
{
unsigned char sense_b[SENSE_BUFF_LEN];
struct sg_io_hdr io_hdr;
@@ -541,7 +542,8 @@ struct mpage_name_func * get_mpage_name_func(struct mpage_info * mpi)
static char unkn_page_str[64];
-static char * get_page_name(struct mpage_info * mpi)
+static char *
+get_page_name(struct mpage_info * mpi)
{
struct mpage_name_func * mpf;
@@ -565,7 +567,8 @@ static char * get_page_name(struct mpage_info * mpi)
return mpf->name;
}
-static void dump(void *buffer, unsigned int length)
+static void
+dump(void *buffer, unsigned int length)
{
unsigned int i;
@@ -585,7 +588,8 @@ static void dump(void *buffer, unsigned int length)
}
-static int getnbyte(const unsigned char *pnt, int nbyte)
+static int
+getnbyte(const unsigned char *pnt, int nbyte)
{
unsigned int result;
int i;
@@ -598,7 +602,8 @@ static int getnbyte(const unsigned char *pnt, int nbyte)
return result;
}
-static int64_t getnbyte_ll(const unsigned char *pnt, int nbyte)
+static int64_t
+getnbyte_ll(const unsigned char *pnt, int nbyte)
{
int64_t result;
int i;
@@ -612,7 +617,8 @@ static int64_t getnbyte_ll(const unsigned char *pnt, int nbyte)
return result;
}
-static int putnbyte(unsigned char *pnt, unsigned int value,
+static int
+putnbyte(unsigned char *pnt, unsigned int value,
unsigned int nbyte)
{
int i;
@@ -626,7 +632,8 @@ static int putnbyte(unsigned char *pnt, unsigned int value,
#define REASON_SZ 128
-static void check_parm_type(int i)
+static void
+check_parm_type(int i)
{
char reason[REASON_SZ];
@@ -644,7 +651,8 @@ static void check_parm_type(int i)
}
}
-static void bitfield(unsigned char *pageaddr, char * text, int mask, int shift)
+static void
+bitfield(unsigned char *pageaddr, char * text, int mask, int shift)
{
if (x_interface && replace) {
check_parm_type(0);
@@ -657,7 +665,8 @@ static void bitfield(unsigned char *pageaddr, char * text, int mask, int shift)
}
#if 0
-static void notbitfield(unsigned char *pageaddr, char * text, int mask,
+static void
+notbitfield(unsigned char *pageaddr, char * text, int mask,
int shift)
{
if (modifiable) {
@@ -675,7 +684,8 @@ static void notbitfield(unsigned char *pageaddr, char * text, int mask,
}
#endif
-static void intfield(unsigned char * pageaddr, int nbytes, char * text)
+static void
+intfield(unsigned char * pageaddr, int nbytes, char * text)
{
if (x_interface && replace) {
check_parm_type(0);
@@ -686,7 +696,8 @@ static void intfield(unsigned char * pageaddr, int nbytes, char * text)
printf("%-35s%d\n", text, getnbyte(pageaddr, nbytes));
}
-static void hexfield(unsigned char * pageaddr, int nbytes, char * text)
+static void
+hexfield(unsigned char * pageaddr, int nbytes, char * text)
{
if (x_interface && replace) {
check_parm_type(0);
@@ -697,7 +708,8 @@ static void hexfield(unsigned char * pageaddr, int nbytes, char * text)
printf("%-35s0x%x\n", text, getnbyte(pageaddr, nbytes));
}
-static void hexdatafield(unsigned char * pageaddr, int nbytes, char * text)
+static void
+hexdatafield(unsigned char * pageaddr, int nbytes, char * text)
{
if (x_interface && replace) {
unsigned char *ptr;
@@ -751,7 +763,8 @@ static void hexdatafield(unsigned char * pageaddr, int nbytes, char * text)
/* Offset into mode sense (6 or 10 byte) response that actual mode page
* starts at (relative to resp[0]). Returns -1 if problem */
-static int modePageOffset(const unsigned char * resp, int len, int modese_6)
+static int
+modePageOffset(const unsigned char * resp, int len, int modese_6)
{
int bd_len;
int resp_len = 0;
@@ -782,8 +795,9 @@ static int modePageOffset(const unsigned char * resp, int len, int modese_6)
}
/* Reads mode (sub-)page via 6 byte MODE SENSE, returns 0 if ok */
-static int get_mode_page6(struct mpage_info * mpi, int dbd,
- unsigned char * resp, int sngl_fetch)
+static int
+get_mode_page6(struct mpage_info * mpi, int dbd, unsigned char * resp,
+ int sngl_fetch)
{
int status, off;
unsigned char cmd[6];
@@ -852,8 +866,9 @@ static int get_mode_page6(struct mpage_info * mpi, int dbd,
}
/* Reads mode (sub-)page via 10 byte MODE SENSE, returns 0 if ok */
-static int get_mode_page10(struct mpage_info * mpi, int llbaa, int dbd,
- unsigned char * resp, int sngl_fetch)
+static int
+get_mode_page10(struct mpage_info * mpi, int llbaa, int dbd,
+ unsigned char * resp, int sngl_fetch)
{
int status, off;
unsigned char cmd[10];
@@ -926,8 +941,8 @@ static int get_mode_page10(struct mpage_info * mpi, int llbaa, int dbd,
return status;
}
-static int get_mode_page(struct mpage_info * mpi, int dbd,
- unsigned char * resp)
+static int
+get_mode_page(struct mpage_info * mpi, int dbd, unsigned char * resp)
{
int res;
@@ -952,8 +967,9 @@ static int get_mode_page(struct mpage_info * mpi, int dbd,
/* Contents should point to the mode parameter header that we obtained
in a prior read operation. This way we do not have to work out the
format of the beast. Assume 0 or 1 block descriptors. */
-static int put_mode_page6(struct mpage_info * mpi,
- const unsigned char * msense6_resp, int sp_bit)
+static int
+put_mode_page6(struct mpage_info * mpi, const unsigned char * msense6_resp,
+ int sp_bit)
{
int status;
int bdlen, resplen;
@@ -1007,8 +1023,9 @@ static int put_mode_page6(struct mpage_info * mpi,
/* Contents should point to the mode parameter header that we obtained
in a prior read operation. This way we do not have to work out the
format of the beast. Assume 0 or 1 block descriptors. */
-static int put_mode_page10(struct mpage_info * mpi,
- const unsigned char * msense10_resp, int sp_bit)
+static int
+put_mode_page10(struct mpage_info * mpi, const unsigned char * msense10_resp,
+ int sp_bit)
{
int status;
int bdlen, resplen;
@@ -1062,8 +1079,8 @@ static int put_mode_page10(struct mpage_info * mpi,
return status;
}
-static int put_mode_page(struct mpage_info * mpi,
- const unsigned char * msense_resp)
+static int
+put_mode_page(struct mpage_info * mpi, const unsigned char * msense_resp)
{
if (mode6byte)
return put_mode_page6(mpi, msense_resp, ! negate_sp_bit);
@@ -1071,8 +1088,9 @@ static int put_mode_page(struct mpage_info * mpi,
return put_mode_page10(mpi, msense_resp, ! negate_sp_bit);
}
-int setup_mode_page(struct mpage_info * mpi, int nparam,
- unsigned char * buff, unsigned char ** o_pagestart)
+static int
+setup_mode_page(struct mpage_info * mpi, int nparam, unsigned char * buff,
+ unsigned char ** o_pagestart)
{
int status, offset, rem_pglen;
unsigned char * pgp;
@@ -1105,8 +1123,9 @@ int setup_mode_page(struct mpage_info * mpi, int nparam,
return 0;
}
-static int get_protocol_id(int port_not_lu, unsigned char * buff,
- int * proto_idp, int * offp)
+static int
+get_protocol_id(int port_not_lu, unsigned char * buff, int * proto_idp,
+ int * offp)
{
int status, off, proto_id, spf;
struct mpage_info mp_i;
@@ -1134,7 +1153,8 @@ static int get_protocol_id(int port_not_lu, unsigned char * buff,
return 0;
}
-static int disk_geometry(struct mpage_info * mpi, const char * prefix)
+static int
+disk_geometry(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -1164,7 +1184,8 @@ static int disk_geometry(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int common_disconnect_reconnect(struct mpage_info * mpi,
+static int
+common_disconnect_reconnect(struct mpage_info * mpi,
const char * prefix)
{
int status;
@@ -1199,7 +1220,8 @@ static int common_disconnect_reconnect(struct mpage_info * mpi,
}
-static int common_control(struct mpage_info * mpi, const char * prefix)
+static int
+common_control(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -1242,7 +1264,8 @@ static int common_control(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int common_control_extension(struct mpage_info * mpi, const char * prefix)
+static int
+common_control_extension(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -1270,7 +1293,8 @@ static int common_control_extension(struct mpage_info * mpi, const char * prefix
return 0;
}
-static int common_informational(struct mpage_info * mpi, const char * prefix)
+static int
+common_informational(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -1302,7 +1326,8 @@ static int common_informational(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int disk_error_recovery(struct mpage_info * mpi, const char * prefix)
+static int
+disk_error_recovery(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -1338,7 +1363,8 @@ static int disk_error_recovery(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int cdvd_error_recovery(struct mpage_info * mpi, const char * prefix)
+static int
+cdvd_error_recovery(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -1370,7 +1396,8 @@ static int cdvd_error_recovery(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int cdvd_mrw(struct mpage_info * mpi, const char * prefix)
+static int
+cdvd_mrw(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -1393,7 +1420,8 @@ static int cdvd_mrw(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int disk_notch_parameters(struct mpage_info * mpi, const char * prefix)
+static int
+disk_notch_parameters(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -1444,7 +1472,9 @@ static int disk_notch_parameters(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static char *formatname(int format) {
+static char *
+formatname(int format)
+{
switch(format) {
case 0x0: return "logical block addresses (32 bit)";
case 0x3: return "logical block addresses (64 bit)";
@@ -1456,7 +1486,8 @@ static char *formatname(int format) {
return "Weird, unknown format";
}
-static int read_defect_list(int grown_only)
+static int
+read_defect_list(int grown_only)
{
int i, len, reallen, table, k, defect_format;
int status = 0;
@@ -1609,7 +1640,8 @@ static int read_defect_list(int grown_only)
}
if (len > 0xfff0 && heapp != NULL) {
cmd12[0] = 0xB7; /* READ DEFECT DATA (12) */
- cmd12[1] = (table ? 0x08 : 0x10) | defectformat;/* List, Format */
+ cmd12[1] = (table ? 0x08 : 0x10) | defectformat;
+ /* List, Format */
cmd12[2] = 0x00; /* (reserved) */
cmd12[3] = 0x00; /* (reserved) */
cmd12[4] = 0x00; /* (reserved) */
@@ -1660,7 +1692,8 @@ trytenbyte:
}
cmd[0] = 0x37; /* READ DEFECT DATA (10) */
cmd[1] = 0x00;
- cmd[2] = (table ? 0x08 : 0x10) | defectformat;/* List, Format */
+ cmd[2] = (table ? 0x08 : 0x10) | defectformat;
+ /* List, Format */
cmd[3] = 0x00; /* (reserved) */
cmd[4] = 0x00; /* (reserved) */
cmd[5] = 0x00; /* (reserved) */
@@ -1702,8 +1735,8 @@ trytenbyte:
switch (defect_format) {
case 4: /* bytes from index */
while (len > 0) {
- snprintf((char *)cbuffer1, 40, "%6d:%3u:%8d", getnbyte(df, 3),
- df[3], getnbyte(df + 4, 4));
+ snprintf((char *)cbuffer1, 40, "%6d:%3u:%8d",
+ getnbyte(df, 3), df[3], getnbyte(df + 4, 4));
if (sorthead == 0)
printf("%19s", (char *)cbuffer1);
else
@@ -1719,7 +1752,8 @@ trytenbyte:
}
case 5: /* physical sector */
while (len > 0) {
- snprintf((char *)cbuffer1, 40, "%6d:%2u:%5d", getnbyte(df, 3),
+ snprintf((char *)cbuffer1, 40, "%6d:%2u:%5d",
+ getnbyte(df, 3),
df[3], getnbyte(df + 4, 4));
if (sorthead == 0)
printf("%15s", (char *)cbuffer1);
@@ -1787,7 +1821,8 @@ trytenbyte:
return status;
}
-static int disk_cache(struct mpage_info * mpi, const char * prefix)
+static int
+disk_cache(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -1830,7 +1865,8 @@ static int disk_cache(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int disk_format(struct mpage_info * mpi, const char * prefix)
+static int
+disk_format(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -1866,8 +1902,8 @@ static int disk_format(struct mpage_info * mpi, const char * prefix)
}
-static int disk_verify_error_recovery(struct mpage_info * mpi,
- const char * prefix)
+static int
+disk_verify_error_recovery(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -1898,8 +1934,8 @@ static int disk_verify_error_recovery(struct mpage_info * mpi,
}
#if 0
-static int peripheral_device_page(struct mpage_info * mpi,
- const char * prefix)
+static int
+peripheral_device_page(struct mpage_info * mpi, const char * prefix)
{
static char *idents[] =
{
@@ -1969,7 +2005,8 @@ static int peripheral_device_page(struct mpage_info * mpi,
}
#endif
-static int common_power_condition(struct mpage_info * mpi, const char * prefix)
+static int
+common_power_condition(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -1996,7 +2033,8 @@ static int common_power_condition(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int disk_xor_control(struct mpage_info * mpi, const char * prefix)
+static int
+disk_xor_control(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2024,7 +2062,8 @@ static int disk_xor_control(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int disk_background(struct mpage_info * mpi, const char * prefix)
+static int
+disk_background(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2052,7 +2091,8 @@ static int disk_background(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int optical_memory(struct mpage_info * mpi, const char * prefix)
+static int
+optical_memory(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2076,7 +2116,8 @@ static int optical_memory(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int cdvd_write_param(struct mpage_info * mpi, const char * prefix)
+static int
+cdvd_write_param(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2119,7 +2160,8 @@ static int cdvd_write_param(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int cdvd_audio_control(struct mpage_info * mpi, const char * prefix)
+static int
+cdvd_audio_control(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2152,7 +2194,8 @@ static int cdvd_audio_control(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int cdvd_timeout(struct mpage_info * mpi, const char * prefix)
+static int
+cdvd_timeout(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2181,7 +2224,8 @@ static int cdvd_timeout(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int cdvd_device_param(struct mpage_info * mpi, const char * prefix)
+static int
+cdvd_device_param(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2210,7 +2254,8 @@ static int cdvd_device_param(struct mpage_info * mpi, const char * prefix)
/* This is not a standard t10.org MMC mode page (it is now "protocol specific
lu" mode page). This definition was found in Hitachi GF-2050/GF-2055
DVD-RAM drive SCSI reference manual. */
-static int cdvd_feature(struct mpage_info * mpi, const char * prefix)
+static int
+cdvd_feature(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2245,7 +2290,8 @@ static int cdvd_feature(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int cdvd_mm_capab(struct mpage_info * mpi, const char * prefix)
+static int
+cdvd_mm_capab(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2317,7 +2363,8 @@ static int cdvd_mm_capab(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int cdvd_cache(struct mpage_info * mpi, const char * prefix)
+static int
+cdvd_cache(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2341,7 +2388,8 @@ static int cdvd_cache(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int tape_data_compression(struct mpage_info * mpi, const char * prefix)
+static int
+tape_data_compression(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2370,7 +2418,8 @@ static int tape_data_compression(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int tape_dev_config(struct mpage_info * mpi, const char * prefix)
+static int
+tape_dev_config(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2418,7 +2467,8 @@ static int tape_dev_config(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int tape_medium_part1(struct mpage_info * mpi, const char * prefix)
+static int
+tape_medium_part1(struct mpage_info * mpi, const char * prefix)
{
int status, off, len;
unsigned char *pagestart;
@@ -2465,7 +2515,8 @@ static int tape_medium_part1(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int tape_medium_part2_4(struct mpage_info * mpi, const char * prefix)
+static int
+tape_medium_part2_4(struct mpage_info * mpi, const char * prefix)
{
int status, off, len;
unsigned char *pagestart;
@@ -2501,7 +2552,8 @@ static int tape_medium_part2_4(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int ses_services_manag(struct mpage_info * mpi, const char * prefix)
+static int
+ses_services_manag(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2526,7 +2578,8 @@ static int ses_services_manag(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int fcp_proto_spec_lu(struct mpage_info * mpi, const char * prefix)
+static int
+fcp_proto_spec_lu(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2551,7 +2604,8 @@ static int fcp_proto_spec_lu(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int sas_proto_spec_lu(struct mpage_info * mpi, const char * prefix)
+static int
+sas_proto_spec_lu(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2575,7 +2629,8 @@ static int sas_proto_spec_lu(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int common_proto_spec_lu(struct mpage_info * mpi, const char * prefix)
+static int
+common_proto_spec_lu(struct mpage_info * mpi, const char * prefix)
{
int status, proto_id;
@@ -2590,7 +2645,8 @@ static int common_proto_spec_lu(struct mpage_info * mpi, const char * prefix)
return DECODE_FAILED_TRY_HEX;
}
-static int fcp_proto_spec_port(struct mpage_info * mpi, const char * prefix)
+static int
+fcp_proto_spec_port(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2624,7 +2680,8 @@ static int fcp_proto_spec_port(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int spi4_proto_spec_port(struct mpage_info * mpi, const char * prefix)
+static int
+spi4_proto_spec_port(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2649,7 +2706,8 @@ static int spi4_proto_spec_port(struct mpage_info * mpi, const char * prefix)
}
/* Protocol specific mode page for SAS, short format (subpage 0) */
-static int sas_proto_spec_port(struct mpage_info * mpi, const char * prefix)
+static int
+sas_proto_spec_port(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2675,7 +2733,8 @@ static int sas_proto_spec_port(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int common_proto_spec_port(struct mpage_info * mpi, const char * prefix)
+static int
+common_proto_spec_port(struct mpage_info * mpi, const char * prefix)
{
int status, proto_id;
@@ -2692,7 +2751,8 @@ static int common_proto_spec_port(struct mpage_info * mpi, const char * prefix)
return DECODE_FAILED_TRY_HEX;
}
-static int spi4_margin_control(struct mpage_info * mpi, const char * prefix)
+static int
+spi4_margin_control(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2722,8 +2782,8 @@ static int spi4_margin_control(struct mpage_info * mpi, const char * prefix)
}
/* Protocol specific mode page for SAS, phy control + discover (subpage 1) */
-static int sas_phy_control_discover(struct mpage_info * mpi,
- const char * prefix)
+static int
+sas_phy_control_discover(struct mpage_info * mpi, const char * prefix)
{
int status, off, num_phys, k;
unsigned char *pagestart;
@@ -2776,8 +2836,8 @@ static int sas_phy_control_discover(struct mpage_info * mpi,
}
-static int common_proto_spec_port_sp1(struct mpage_info * mpi,
- const char * prefix)
+static int
+common_proto_spec_port_sp1(struct mpage_info * mpi, const char * prefix)
{
int status, proto_id;
@@ -2792,7 +2852,8 @@ static int common_proto_spec_port_sp1(struct mpage_info * mpi,
return DECODE_FAILED_TRY_HEX;
}
-static int spi4_training_config(struct mpage_info * mpi, const char * prefix)
+static int
+spi4_training_config(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2844,7 +2905,8 @@ static int spi4_training_config(struct mpage_info * mpi, const char * prefix)
}
/* SAS(2) SSP, shared protocol specific port mode subpage (subpage 2) */
-static int sas_shared_spec_port(struct mpage_info * mpi, const char * prefix)
+static int
+sas_shared_spec_port(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2869,8 +2931,8 @@ static int sas_shared_spec_port(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int common_proto_spec_port_sp2(struct mpage_info * mpi,
- const char * prefix)
+static int
+common_proto_spec_port_sp2(struct mpage_info * mpi, const char * prefix)
{
int status, proto_id;
@@ -2885,7 +2947,8 @@ static int common_proto_spec_port_sp2(struct mpage_info * mpi,
return DECODE_FAILED_TRY_HEX;
}
-static int spi4_negotiated(struct mpage_info * mpi, const char * prefix)
+static int
+spi4_negotiated(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2916,7 +2979,8 @@ static int spi4_negotiated(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static int spi4_report_xfer(struct mpage_info * mpi, const char * prefix)
+static int
+spi4_report_xfer(struct mpage_info * mpi, const char * prefix)
{
int status;
unsigned char *pagestart;
@@ -2944,8 +3008,9 @@ static int spi4_report_xfer(struct mpage_info * mpi, const char * prefix)
return 0;
}
-static void print_hex_page(struct mpage_info * mpi, const char * prefix,
- unsigned char *pagestart, int off, int len)
+static void
+print_hex_page(struct mpage_info * mpi, const char * prefix,
+ unsigned char *pagestart, int off, int len)
{
int k;
char * pg_name;
@@ -2981,7 +3046,8 @@ static void print_hex_page(struct mpage_info * mpi, const char * prefix,
printf("\n");
}
-static int do_user_page(struct mpage_info * mpi, int decode_in_hex)
+static int
+do_user_page(struct mpage_info * mpi, int decode_in_hex)
{
int status = 0;
int len, off, res, done;
@@ -3023,7 +3089,7 @@ static int do_user_page(struct mpage_info * mpi, int decode_in_hex)
local_mp_i.subpage = (pagestart[0] & 0x40) ? pagestart[1] : 0;
if(0 == local_mp_i.page) { /* page==0 vendor (unknown) format */
off = 0;
- len = mpi->resp_len - offset; /* should be last listed page */
+ len = mpi->resp_len - offset; /* should be last listed page */
} else if (local_mp_i.subpage) {
off = 4;
len = (pagestart[2] << 8) + pagestart[3] + 4;
@@ -3058,8 +3124,8 @@ static int do_user_page(struct mpage_info * mpi, int decode_in_hex)
if (multiple && x_interface && !replace) {
if (local_mp_i.subpage)
snprintf(prefix, sizeof(prefix), "sginfo -u 0x%x,0x%x"
- " -XR %s ", local_mp_i.page, local_mp_i.subpage,
- device_name);
+ " -XR %s ", local_mp_i.page,
+ local_mp_i.subpage, device_name);
else
snprintf(prefix, sizeof(prefix), "sginfo -u 0x%x -XR "
"%s ", local_mp_i.page, device_name);
@@ -3073,8 +3139,8 @@ static int do_user_page(struct mpage_info * mpi, int decode_in_hex)
return status;
}
-static int do_inquiry(int * peri_type, int * resp_byte6,
- int inquiry_verbosity)
+static int
+do_inquiry(int * peri_type, int * resp_byte6, int inquiry_verbosity)
{
int status;
unsigned char cmd[6];
@@ -3162,7 +3228,8 @@ static int do_inquiry(int * peri_type, int * resp_byte6,
}
-static int do_serial_number()
+static int
+do_serial_number(void)
{
int status, pagelen;
unsigned char cmd[6];
@@ -3265,7 +3332,8 @@ typedef struct my_scsi_idlun
#define MDEV_NAME_SZ 256
-static void make_dev_name(char * fname, int k, int do_numeric)
+static void
+make_dev_name(char * fname, int k, int do_numeric)
{
char buff[MDEV_NAME_SZ];
size_t len;
@@ -3292,7 +3360,8 @@ static Sg_map sg_map_arr[MAX_SG_DEVS + 1];
#define MAX_HOLES 4
/* Print out a list of the known devices on the system */
-static void show_devices(int raw)
+static void
+show_devices(int raw)
{
int k, j, fd, err, bus;
My_scsi_idlun m_idlun;
@@ -3333,7 +3402,8 @@ static void show_devices(int raw)
if ( strncmp("sg",entry->d_name,2) == 0 ) {
continue;
}
- if ( strncmp("sd",entry->d_name,2) == 0 && isdigit(entry->d_name[strlen(entry->d_name)-1]) ) {
+ if ((strncmp("sd",entry->d_name,2) == 0) &&
+ isdigit(entry->d_name[strlen(entry->d_name)-1])) {
continue;
}
@@ -3460,7 +3530,8 @@ static void show_devices(int raw)
#define DEVNAME_SZ 256
-static int open_sg_io_dev(char * devname)
+static int
+open_sg_io_dev(char * devname)
{
int fd, fdrw, err, bus, bbus, k, v;
My_scsi_idlun m_idlun, mm_idlun;
@@ -3560,13 +3631,16 @@ static int open_sg_io_dev(char * devname)
return fd;
}
-static void usage(char *errtext)
+static void
+usage(char *errtext)
{
if (errtext)
fprintf(stderr, "Error: sginfo: %s\n", errtext);
- fprintf(stderr, "Usage: sginfo [-options] [device] [replacement_values]\n");
+ fprintf(stderr, "Usage: sginfo [-options] [device] "
+ "[replacement_values]\n");
fputs("\tAllowed options are:\n"
- "\t-6 Do 6 byte mode sense and select commands (def: 10 bytes).\n"
+ "\t-6 Do 6 byte mode sense and select commands (def: 10 "
+ "bytes).\n"
"\t-a Display inquiry info, serial # and all mode pages.\n"
"\t-A Similar to '-a' but displays all subpages as well.\n"
"\t-c Access Caching Page.\n"
@@ -3820,7 +3894,8 @@ int main(int argc, char *argv[])
if ((len & 1) || (len != (int)strspn(argv[optind + j] + 1,
"0123456789ABCDEFabcdef")))
- usage("Odd number of chars or non-hex digit in @hexdatafield");
+ usage("Odd number of chars or non-hex digit in "
+ "@hexdatafield");
replacement_values[j] = (unsigned long) argv[optind + j];
is_hex[j] = 1;
diff --git a/src/sgm_dd.c b/src/sgm_dd.c
index 2377c403..209a183d 100644
--- a/src/sgm_dd.c
+++ b/src/sgm_dd.c
@@ -65,9 +65,9 @@
/* #define SG_WANT_SHARED_MMAP_IO 1 */
#ifdef SG_WANT_SHARED_MMAP_IO
-static char * version_str = "1.36 20120907 shared_mmap";
+static char * version_str = "1.37 20121211 shared_mmap";
#else
-static char * version_str = "1.36 20111014";
+static char * version_str = "1.37 20121211";
#endif
#define DEF_BLOCK_SIZE 512
@@ -177,7 +177,8 @@ print_stats()
{
if (0 != dd_count)
fprintf(stderr, " remaining block count=%"PRId64"\n", dd_count);
- fprintf(stderr, "%"PRId64"+%d records in\n", in_full - in_partial, in_partial);
+ fprintf(stderr, "%"PRId64"+%d records in\n", in_full - in_partial,
+ in_partial);
fprintf(stderr, "%"PRId64"+%d records out\n", out_full - out_partial,
out_partial);
}
@@ -373,8 +374,8 @@ scsi_read_capacity(int sg_fd, int64_t * num_sect, int * sect_sz)
(rcBuff[6] << 8) | rcBuff[7];
}
if (verbose)
- fprintf(stderr, " number of blocks=%"PRId64" [0x%"PRIx64"], block "
- "size=%d\n", *num_sect, *num_sect, *sect_sz);
+ fprintf(stderr, " number of blocks=%" PRId64 " [0x%" PRIx64
+ "], block size=%d\n", *num_sect, *num_sect, *sect_sz);
return 0;
}
@@ -398,8 +399,9 @@ read_blkdev_capacity(int sg_fd, int64_t * num_sect, int * sect_sz)
}
*num_sect = ((int64_t)ull / (int64_t)*sect_sz);
if (verbose)
- fprintf(stderr, " [bgs64] number of blocks=%"PRId64" [0x%"PRIx64"], "
- "block size=%d\n", *num_sect, *num_sect, *sect_sz);
+ fprintf(stderr, " [bgs64] number of blocks=%" PRId64 " [0x%"
+ PRIx64 "], block size=%d\n", *num_sect, *num_sect,
+ *sect_sz);
#else
unsigned long ul;
@@ -409,8 +411,9 @@ read_blkdev_capacity(int sg_fd, int64_t * num_sect, int * sect_sz)
}
*num_sect = (int64_t)ul;
if (verbose)
- fprintf(stderr, " [bgs] number of blocks=%"PRId64" [0x%"PRIx64"], "
- " block size=%d\n", *num_sect, *num_sect, *sect_sz);
+ fprintf(stderr, " [bgs] number of blocks=%" PRId64 " [0x%"
+ PRIx64 "], block size=%d\n", *num_sect, *num_sect,
+ *sect_sz);
#endif
}
return 0;
@@ -529,8 +532,8 @@ sg_read(int sg_fd, unsigned char * buff, int blocks, int64_t from_block,
int k, res;
if (sg_build_scsi_cdb(rdCmd, cdbsz, blocks, from_block, 0, fua, dpo)) {
- fprintf(stderr, ME "bad rd cdb build, from_block=%"PRId64", blocks=%d\n",
- from_block, blocks);
+ fprintf(stderr, ME "bad rd cdb build, from_block=%" PRId64
+ ", blocks=%d\n", from_block, blocks);
return SG_LIB_SYNTAX_ERROR;
}
memset(&io_hdr, 0, sizeof(struct sg_io_hdr));
@@ -932,7 +935,8 @@ main(int argc, char * argv[])
}
if (blk_sz <= 0) {
blk_sz = DEF_BLOCK_SIZE;
- fprintf(stderr, "Assume default 'bs' (block size) of %d bytes\n", blk_sz);
+ fprintf(stderr, "Assume default 'bs' (block size) of %d bytes\n",
+ blk_sz);
}
if ((ibs && (ibs != blk_sz)) || (obs && (obs != blk_sz))) {
fprintf(stderr, "If 'ibs' or 'obs' given must be same as 'bs'\n");
@@ -958,8 +962,8 @@ main(int argc, char * argv[])
bpt = DEF_BLOCKS_PER_2048TRANSFER;
#ifdef SG_DEBUG
- fprintf(stderr, ME "if=%s skip=%"PRId64" of=%s seek=%"PRId64" count=%"PRId64"\n",
- inf, skip, outf, seek, dd_count);
+ fprintf(stderr, ME "if=%s skip=%" PRId64 " of=%s seek=%" PRId64 " count=%"
+ PRId64 "\n", inf, skip, outf, seek, dd_count);
#endif
install_handler (SIGINT, interrupt_handler);
install_handler (SIGQUIT, interrupt_handler);
@@ -1235,14 +1239,14 @@ main(int argc, char * argv[])
if (out_num_sect > seek)
out_num_sect -= seek;
#ifdef SG_DEBUG
- fprintf(stderr,
- "Start of loop, count=%"PRId64", in_num_sect=%"PRId64", out_num_sect=%"PRId64"\n",
- dd_count, in_num_sect, out_num_sect);
+ fprintf(stderr, "Start of loop, count=%" PRId64 ", in_num_sect=%"
+ PRId64 ", out_num_sect=%"PRId64"\n", dd_count, in_num_sect,
+ out_num_sect);
#endif
if (in_num_sect > 0) {
if (out_num_sect > 0)
dd_count = (in_num_sect > out_num_sect) ? out_num_sect :
- in_num_sect;
+ in_num_sect;
else
dd_count = in_num_sect;
}
@@ -1431,7 +1435,8 @@ main(int argc, char * argv[])
break;
}
else if (res < blocks * blk_sz) {
- fprintf(stderr, "output file probably full, seek=%"PRId64" ", seek);
+ fprintf(stderr, "output file probably full, seek=%" PRId64
+ " ", seek);
blocks = res / blk_sz;
out_full += blocks;
if ((res % blk_sz) > 0)
diff --git a/src/sgp_dd.c b/src/sgp_dd.c
index 04441412..0f5c9b97 100644
--- a/src/sgp_dd.c
+++ b/src/sgp_dd.c
@@ -1,3 +1,29 @@
+/* A utility program for copying files. Specialised for "files" that
+* represent devices that understand the SCSI command set.
+*
+* Copyright (C) 1999 - 2012 D. Gilbert and P. Allworth
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2, or (at your option)
+* any later version.
+
+ This program is a specialisation of the Unix "dd" command in which
+ one or both of the given files is a scsi generic device or a raw
+ device. A block size ('bs') is assumed to be 512 if not given. This
+ program complains if 'ibs' or 'obs' are given with some other value
+ than 'bs'. If 'if' is not given or 'if=-' then stdin is assumed. If
+ 'of' is not given or 'of=-' then stdout assumed.
+
+ A non-standard argument "bpt" (blocks per transfer) is added to control
+ the maximum number of blocks in each transfer. The default value is 128.
+ For example if "bs=512" and "bpt=32" then a maximum of 32 blocks (16 KiB
+ in this case) are transferred to or from the sg device in a single SCSI
+ command.
+
+ This version is designed for the linux kernel 2.4, 2.6 and 3 series.
+
+*/
+
#define _XOPEN_SOURCE 500
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
@@ -30,33 +56,8 @@
#include "sg_cmds_basic.h"
#include "sg_io_linux.h"
-/* A utility program for copying files. Specialised for "files" that
-* represent devices that understand the SCSI command set.
-*
-* Copyright (C) 1999 - 2012 D. Gilbert and P. Allworth
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, or (at your option)
-* any later version.
-
- This program is a specialisation of the Unix "dd" command in which
- one or both of the given files is a scsi generic device or a raw
- device. A block size ('bs') is assumed to be 512 if not given. This
- program complains if 'ibs' or 'obs' are given with some other value
- than 'bs'. If 'if' is not given or 'if=-' then stdin is assumed. If
- 'of' is not given or 'of=-' then stdout assumed.
- A non-standard argument "bpt" (blocks per transfer) is added to control
- the maximum number of blocks in each transfer. The default value is 128.
- For example if "bs=512" and "bpt=32" then a maximum of 32 blocks (16 KiB
- in this case) are transferred to or from the sg device in a single SCSI
- command.
-
- This version is designed for the linux kernel 2.4, 2.6 and 3 series.
-
-*/
-
-static char * version_str = "5.42 20120907";
+static char * version_str = "5.43 20121211";
#define DEF_BLOCK_SIZE 512
#define DEF_BLOCKS_PER_TRANSFER 128
@@ -227,8 +228,8 @@ print_stats(const char * str)
fprintf(stderr, " remaining block count=%"PRId64"\n",
rcoll.out_rem_count);
infull = dd_count - rcoll.in_rem_count;
- fprintf(stderr, "%s%"PRId64"+%d records in\n", str, infull - rcoll.in_partial,
- rcoll.in_partial);
+ fprintf(stderr, "%s%"PRId64"+%d records in\n", str,
+ infull - rcoll.in_partial, rcoll.in_partial);
outfull = dd_count - rcoll.out_rem_count;
fprintf(stderr, "%s%"PRId64"+%d records out\n", str,
@@ -858,8 +859,8 @@ sg_in_operation(Rq_coll * clp, Rq_elem * rep)
return;
} else {
memset(rep->buffp, 0, rep->num_blks * rep->bs);
- fprintf(stderr, ">> substituted zeros for in blk=%"PRId64" for "
- "%d bytes\n", rep->blk, rep->num_blks * rep->bs);
+ fprintf(stderr, ">> substituted zeros for in blk=%" PRId64
+ " for %d bytes\n", rep->blk, rep->num_blks * rep->bs);
}
/* fall through */
case 0:
@@ -1333,8 +1334,8 @@ main(int argc, char * argv[])
return SG_LIB_SYNTAX_ERROR;
}
if (rcoll.debug)
- fprintf(stderr, ME "if=%s skip=%"PRId64" of=%s seek=%"PRId64" count=%"PRId64"\n",
- inf, skip, outf, seek, dd_count);
+ fprintf(stderr, ME "if=%s skip=%" PRId64 " of=%s seek=%" PRId64
+ " count=%" PRId64 "\n", inf, skip, outf, seek, dd_count);
install_handler(SIGINT, interrupt_handler);
install_handler(SIGQUIT, interrupt_handler);
@@ -1555,8 +1556,9 @@ main(int argc, char * argv[])
dd_count = out_num_sect;
}
if (rcoll.debug > 1)
- fprintf(stderr, "Start of loop, count=%"PRId64", in_num_sect=%"PRId64", "
- "out_num_sect=%"PRId64"\n", dd_count, in_num_sect, out_num_sect);
+ fprintf(stderr, "Start of loop, count=%" PRId64 ", in_num_sect=%"
+ PRId64 ", out_num_sect=%" PRId64 "\n", dd_count, in_num_sect,
+ out_num_sect);
if (dd_count < 0) {
fprintf(stderr, "Couldn't calculate count, please give one\n");
return SG_LIB_CAT_OTHER;
@@ -1669,8 +1671,8 @@ main(int argc, char * argv[])
close(rcoll.outfd);
res = exit_status;
if (0 != rcoll.out_count) {
- fprintf(stderr, ">>>> Some error occurred, remaining blocks=%"PRId64"\n",
- rcoll.out_count);
+ fprintf(stderr, ">>>> Some error occurred, remaining blocks=%"
+ PRId64 "\n", rcoll.out_count);
if (0 == res)
res = SG_LIB_CAT_OTHER;
}
diff --git a/utils/sg_chk_asc.c b/utils/sg_chk_asc.c
index 5ca2b7d3..7ae402b5 100644
--- a/utils/sg_chk_asc.c
+++ b/utils/sg_chk_asc.c
@@ -163,10 +163,11 @@ printf("\"%s\",\n", b);
continue;
}
num = strlen(cp);
-// fprintf(stderr, "file: asc=%x acsq=%x strlen=%d %s\n", asc, ascq, num, cp);
+// fprintf(stderr, "file: asc=%x acsq=%x strlen=%d %s\n", asc, ascq, num,
+// cp);
// if (num < 20)
// continue;
- if ((num > 6) &&
+ if ((num > 6) &&
((0 == memcmp("ASC", cp, 3)) ||
(0 == memcmp("vendor", cp, 6)))) {
fprintf(stderr, "%x,%x differ, ref: %s, sg_lib_data: "