aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2018-02-22 07:00:28 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2018-02-22 07:00:28 +0000
commit252086533f8af0736c2a4987cd70a44366837ec1 (patch)
tree1f9245e247673fdb6ebea13b9aa559e1f869d78c /examples
parent39ea1b548f21c006c311ace897b221b100bfa88d (diff)
downloadsg3_utils-252086533f8af0736c2a4987cd70a44366837ec1.tar.gz
sg_lib: add sg_if_can2stdout(); use uint8_t instead of unsigned char; Windows pass-through work
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@754 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'examples')
-rw-r--r--examples/sg__sat_identify.c13
-rw-r--r--examples/sg__sat_phy_event.c10
-rw-r--r--examples/sg__sat_set_features.c10
-rw-r--r--examples/sg_excl.c15
-rw-r--r--examples/sg_sat_chk_power.c13
-rw-r--r--examples/sg_sat_smart_rd_data.c13
-rw-r--r--examples/sg_simple16.c11
-rw-r--r--examples/sg_simple5.c12
-rw-r--r--examples/sgq_dd.c23
9 files changed, 62 insertions, 58 deletions
diff --git a/examples/sg__sat_identify.c b/examples/sg__sat_identify.c
index 79c2a3a9..c70eec06 100644
--- a/examples/sg__sat_identify.c
+++ b/examples/sg__sat_identify.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2016 Douglas Gilbert.
+ * Copyright (c) 2006-2018 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
@@ -64,7 +65,7 @@
#define EBUFF_SZ 256
-static char * version_str = "1.03 20160528";
+static char * version_str = "1.04 20180220";
static void usage()
{
@@ -81,14 +82,14 @@ static void usage()
int main(int argc, char * argv[])
{
int sg_fd, k, ok;
- unsigned char apt_cdb[SAT_ATA_PASS_THROUGH16_LEN] =
+ uint8_t apt_cdb[SAT_ATA_PASS_THROUGH16_LEN] =
{SAT_ATA_PASS_THROUGH16, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0};
sg_io_hdr_t io_hdr;
char * file_name = 0;
char ebuff[EBUFF_SZ];
- unsigned char inBuff[ID_RESPONSE_LEN];
- unsigned char sense_buffer[32];
+ uint8_t inBuff[ID_RESPONSE_LEN];
+ uint8_t sense_buffer[32];
int do_packet = 0;
int verbose = 0;
int extend = 0;
@@ -97,7 +98,7 @@ int main(int argc, char * argv[])
int t_dir = 1; /* 0 -> to device, 1 -> from device */
int byte_block = 1; /* 0 -> bytes, 1 -> 512 byte blocks */
int t_length = 2; /* 0 -> no data transferred, 2 -> sector count */
- const unsigned char * cucp;
+ const uint8_t * cucp;
memset(inBuff, 0, sizeof(inBuff));
for (k = 1; k < argc; ++k) {
diff --git a/examples/sg__sat_phy_event.c b/examples/sg__sat_phy_event.c
index fab33393..40f38e19 100644
--- a/examples/sg__sat_phy_event.c
+++ b/examples/sg__sat_phy_event.c
@@ -64,7 +64,7 @@
#define EBUFF_SZ 256
-static const char * version_str = "1.02 20180119";
+static const char * version_str = "1.03 20180220";
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
@@ -146,14 +146,14 @@ static void dStrRaw(const uint8_t * str, int len)
int main(int argc, char * argv[])
{
int sg_fd, c, k, j, ok, res, id, len, vendor;
- unsigned char apt_cdb[SAT_ATA_PASS_THROUGH16_LEN] =
+ uint8_t apt_cdb[SAT_ATA_PASS_THROUGH16_LEN] =
{SAT_ATA_PASS_THROUGH16, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0};
sg_io_hdr_t io_hdr;
char * device_name = 0;
char ebuff[EBUFF_SZ];
- unsigned char inBuff[READ_LOG_EXT_RESPONSE_LEN];
- unsigned char sense_buffer[64];
+ uint8_t inBuff[READ_LOG_EXT_RESPONSE_LEN];
+ uint8_t sense_buffer[64];
int hex = 0;
int ignore = 0;
int raw = 0;
@@ -165,7 +165,7 @@ int main(int argc, char * argv[])
int t_dir = 1; /* 0 -> to device, 1 -> from device */
int byte_block = 1; /* 0 -> bytes, 1 -> 512 byte blocks */
int t_length = 2; /* 0 -> no data transferred, 2 -> sector count */
- const unsigned char * cucp;
+ const uint8_t * cucp;
int ret = 0;
uint64_t ull;
const char * cp;
diff --git a/examples/sg__sat_set_features.c b/examples/sg__sat_set_features.c
index 215d2351..fc7a8cc2 100644
--- a/examples/sg__sat_set_features.c
+++ b/examples/sg__sat_set_features.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2016 Douglas Gilbert.
+ * Copyright (c) 2006-2018 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -58,7 +58,7 @@
#define EBUFF_SZ 256
-static char * version_str = "1.04 20160528";
+static char * version_str = "1.05 20180220";
static struct option long_options[] = {
{"count", required_argument, 0, 'c'},
@@ -100,13 +100,13 @@ void usage()
int main(int argc, char * argv[])
{
int sg_fd, c, k;
- unsigned char apt_cdb[SAT_ATA_PASS_THROUGH16_LEN] =
+ uint8_t apt_cdb[SAT_ATA_PASS_THROUGH16_LEN] =
{SAT_ATA_PASS_THROUGH16, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0};
sg_io_hdr_t io_hdr;
char device_name[256];
char ebuff[EBUFF_SZ];
- unsigned char sense_buffer[64];
+ uint8_t sense_buffer[64];
int count = 0;
int feature = 0;
int lba = 0;
@@ -117,7 +117,7 @@ int main(int argc, char * argv[])
int t_dir = 1; /* 0 -> to device, 1 -> from device */
int byte_block = 1; /* 0 -> bytes, 1 -> 512 byte blocks */
int t_length = 0; /* 0 -> no data transferred, 2 -> sector count */
- const unsigned char * bp = NULL;
+ const uint8_t * bp = NULL;
memset(device_name, 0, sizeof(device_name));
while (1) {
diff --git a/examples/sg_excl.c b/examples/sg_excl.c
index de84905c..8cbab750 100644
--- a/examples/sg_excl.c
+++ b/examples/sg_excl.c
@@ -2,6 +2,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
@@ -14,7 +15,7 @@
executing a SCSI INQUIRY command and a
TEST UNIT READY command using the SCSI generic (sg) driver
-* Copyright (C) 2003-2013 D. Gilbert
+* Copyright (C) 2003-2018 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)
@@ -22,7 +23,7 @@
Invocation: sg_excl [-x] <sg_device>
- Version 3.59 (20160528)
+ Version 3.60 (20180220)
6 byte INQUIRY command:
[0x12][ |lu][pg cde][res ][al len][cntrl ]
@@ -43,15 +44,13 @@
int main(int argc, char * argv[])
{
int sg_fd, k, ok /*, sg_fd2 */;
- unsigned char inq_cdb [INQ_CMD_LEN] =
- {0x12, 0, 0, 0, INQ_REPLY_LEN, 0};
- unsigned char tur_cdb [TUR_CMD_LEN] =
- {0x00, 0, 0, 0, 0, 0};
- unsigned char inqBuff[INQ_REPLY_LEN];
+ uint8_t inq_cdb [INQ_CMD_LEN] = {0x12, 0, 0, 0, INQ_REPLY_LEN, 0};
+ uint8_t tur_cdb [TUR_CMD_LEN] = {0x00, 0, 0, 0, 0, 0};
+ uint8_t inqBuff[INQ_REPLY_LEN];
sg_io_hdr_t io_hdr;
char * file_name = 0;
char ebuff[EBUFF_SZ];
- unsigned char sense_buffer[32];
+ uint8_t sense_buffer[32];
int do_extra = 0;
for (k = 1; k < argc; ++k) {
diff --git a/examples/sg_sat_chk_power.c b/examples/sg_sat_chk_power.c
index 5e65e927..6bf2c979 100644
--- a/examples/sg_sat_chk_power.c
+++ b/examples/sg_sat_chk_power.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2016 Douglas Gilbert.
+ * Copyright (c) 2006-2018 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
@@ -56,7 +57,7 @@
#define EBUFF_SZ 256
-static const char * version_str = "1.05 20160528";
+static const char * version_str = "1.06 20180220";
#if 0
@@ -64,7 +65,7 @@ static const char * version_str = "1.05 20160528";
* command, else returns 0. If returns 0 (expected sense data not found)
* then '\0' placed in first byte of bp. */
static int
-sg_sat_decode_fixed_sense(const unsigned char * sp, int slen, char * bp,
+sg_sat_decode_fixed_sense(const uint8_t * sp, int slen, char * bp,
int max_blen, int verbose)
{
int n;
@@ -98,13 +99,13 @@ sg_sat_decode_fixed_sense(const unsigned char * sp, int slen, char * bp,
int main(int argc, char * argv[])
{
int sg_fd, k;
- unsigned char apt_cdb[SAT_ATA_PASS_THROUGH16_LEN] =
+ uint8_t apt_cdb[SAT_ATA_PASS_THROUGH16_LEN] =
{SAT_ATA_PASS_THROUGH16, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0};
sg_io_hdr_t io_hdr;
char * file_name = 0;
char ebuff[EBUFF_SZ];
- unsigned char sense_buffer[64];
+ uint8_t sense_buffer[64];
int verbose = 0;
int extend = 0;
int chk_cond = 1; /* set to 1 to read register(s) back */
@@ -112,7 +113,7 @@ int main(int argc, char * argv[])
int t_dir = 1; /* 0 -> to device, 1 -> from device */
int byte_block = 1; /* 0 -> bytes, 1 -> 512 byte blocks */
int t_length = 0; /* 0 -> no data transferred, 2 -> sector count */
- const unsigned char * bp = NULL;
+ const uint8_t * bp = NULL;
for (k = 1; k < argc; ++k) {
if (0 == strcmp(argv[k], "-v"))
diff --git a/examples/sg_sat_smart_rd_data.c b/examples/sg_sat_smart_rd_data.c
index 36b824ca..1e7295d3 100644
--- a/examples/sg_sat_smart_rd_data.c
+++ b/examples/sg_sat_smart_rd_data.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2016 Douglas Gilbert.
+ * Copyright (c) 2006-2018 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
@@ -57,19 +58,19 @@
#define EBUFF_SZ 256
-static char * version_str = "1.03 20160528";
+static char * version_str = "1.04 20180220";
int main(int argc, char * argv[])
{
int sg_fd, k, ok;
- unsigned char apt_cdb[SAT_ATA_PASS_THROUGH16_LEN] =
+ uint8_t apt_cdb[SAT_ATA_PASS_THROUGH16_LEN] =
{SAT_ATA_PASS_THROUGH16, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0};
sg_io_hdr_t io_hdr;
char * file_name = 0;
char ebuff[EBUFF_SZ];
- unsigned char inBuff[SMART_READ_DATA_RESPONSE_LEN];
- unsigned char sense_buffer[32];
+ uint8_t inBuff[SMART_READ_DATA_RESPONSE_LEN];
+ uint8_t sense_buffer[32];
int verbose = 0;
int extend = 0;
int chk_cond = 0; /* set to 1 to read register(s) back */
@@ -77,7 +78,7 @@ int main(int argc, char * argv[])
int t_dir = 1; /* 0 -> to device, 1 -> from device */
int byte_block = 1; /* 0 -> bytes, 1 -> 512 byte blocks */
int t_length = 2; /* 0 -> no data transferred, 2 -> sector count */
- const unsigned char * bp = NULL;
+ const uint8_t * bp = NULL;
for (k = 1; k < argc; ++k) {
if (0 == strcmp(argv[k], "-v"))
diff --git a/examples/sg_simple16.c b/examples/sg_simple16.c
index b4ad9582..e119ca34 100644
--- a/examples/sg_simple16.c
+++ b/examples/sg_simple16.c
@@ -2,6 +2,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
@@ -13,7 +14,7 @@
/* This program performs a READ_16 command as scsi mid-level support
16 byte commands from lk 2.4.15
-* Copyright (C) 2001 D. Gilbert
+* Copyright (C) 2001-2018 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)
@@ -21,7 +22,7 @@
Invocation: sg_simple16 <scsi_device>
- Version 1.03 (20160528)
+ Version 1.04 (20180218)
*/
@@ -33,13 +34,13 @@
int main(int argc, char * argv[])
{
int sg_fd, k, ok;
- unsigned char r16_cdb [READ16_CMD_LEN] =
+ uint8_t r16_cdb [READ16_CMD_LEN] =
{0x88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0};
sg_io_hdr_t io_hdr;
char * file_name = 0;
char ebuff[EBUFF_SZ];
- unsigned char inBuff[READ16_REPLY_LEN];
- unsigned char sense_buffer[32];
+ uint8_t inBuff[READ16_REPLY_LEN];
+ uint8_t sense_buffer[32];
for (k = 1; k < argc; ++k) {
if (*argv[k] == '-') {
diff --git a/examples/sg_simple5.c b/examples/sg_simple5.c
index 0471bec8..47bf7a05 100644
--- a/examples/sg_simple5.c
+++ b/examples/sg_simple5.c
@@ -11,7 +11,7 @@
interface. This allows this example program to be ported to
OSes other than linux.
-* Copyright (C) 2006-2007 D. Gilbert
+* Copyright (C) 2006-20018 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)
@@ -19,7 +19,7 @@
Invocation: sg_simple5 [-x] <scsi_device>
- Version 1.02 (20160528)
+ Version 1.03 (20180220)
*/
@@ -33,14 +33,14 @@
int main(int argc, char * argv[])
{
int sg_fd, k, ok, dsize, res, duration, resid, cat, got, slen;
- unsigned char inq_cdb [INQ_CMD_LEN] =
+ uint8_t inq_cdb [INQ_CMD_LEN] =
{0x12, 0, 0, 0, INQ_REPLY_LEN, 0};
- unsigned char tur_cdb [TUR_CMD_LEN] =
+ uint8_t tur_cdb [TUR_CMD_LEN] =
{0x00, 0, 0, 0, 0, 0};
- unsigned char inqBuff[INQ_REPLY_LEN];
+ uint8_t inqBuff[INQ_REPLY_LEN];
char * file_name = 0;
char b[512];
- unsigned char sense_b[32];
+ uint8_t sense_b[32];
int verbose = 0;
struct sg_pt_base * ptvp;
diff --git a/examples/sgq_dd.c b/examples/sgq_dd.c
index 4b6bd041..01693295 100644
--- a/examples/sgq_dd.c
+++ b/examples/sgq_dd.c
@@ -4,6 +4,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
@@ -16,13 +17,13 @@
#include <sys/sysmacros.h>
#include <linux/major.h>
#include <sys/time.h>
-typedef unsigned char u_char; /* horrible, for scsi.h */
+typedef uint8_t u_char; /* horrible, for scsi.h */
#include "sg_lib.h"
#include "sg_io_linux.h"
#include "sg_unaligned.h"
/* A utility program for the Linux OS SCSI generic ("sg") device driver.
-* Copyright (C) 1999-2002 D. Gilbert and P. Allworth
+* Copyright (C) 1999-2018 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)
@@ -48,7 +49,7 @@ typedef unsigned char u_char; /* horrible, for scsi.h */
*/
-static char * version_str = "0.59 20160528";
+static char * version_str = "0.60 20180220";
/* resurrected from "0.55 20020509" */
#define DEF_BLOCK_SIZE 512
@@ -125,11 +126,11 @@ typedef struct request_element
int wr;
int blk;
int num_blks;
- unsigned char * buffp;
- unsigned char * alloc_bp;
+ uint8_t * buffp;
+ uint8_t * alloc_bp;
sg_io_hdr_t io_hdr;
- unsigned char cmd[S_RW_LEN];
- unsigned char sb[SENSE_BUFF_LEN];
+ uint8_t cmd[S_RW_LEN];
+ uint8_t sb[SENSE_BUFF_LEN];
int bs;
int dio;
int dio_incomplete;
@@ -285,9 +286,9 @@ static int
read_capacity(int sg_fd, int * num_sect, int * sect_sz)
{
int res;
- unsigned char rc_cdb [10] = {0x25, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- unsigned char rcBuff[64];
- unsigned char sense_b[64];
+ uint8_t rc_cdb [10] = {0x25, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ uint8_t rcBuff[64];
+ uint8_t sense_b[64];
sg_io_hdr_t io_hdr;
memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
@@ -609,7 +610,7 @@ prepare_rq_elems(Rq_coll * clp, const char * inf, const char * outf)
psz = getpagesize();
if (NULL == (rep->alloc_bp = malloc(sz + psz)))
return 1;
- rep->buffp = (unsigned char *)
+ rep->buffp = (uint8_t *)
(((unsigned long)rep->alloc_bp + psz - 1) & (~(psz - 1)));
rep->qstate = QS_IDLE;
rep->bs = clp->bs;