aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2018-12-07 16:42:06 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2018-12-07 16:42:06 +0000
commit4445eeca7f024eb55a9d5eb5ee6a7183816f0c2e (patch)
tree58e83f896645256c3925ca42ab5e2393aa1c66e9 /examples
parent8101850bc7cd2a05d35b4df3ecfd3f934cff584e (diff)
downloadsg3_utils-4445eeca7f024eb55a9d5eb5ee6a7183816f0c2e.tar.gz
add: SPDX-License-Identifier: BSD-2-Clause (or gpl-2-or-later); testing/sgs_dd.c work
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@797 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'examples')
-rw-r--r--examples/scsi_inquiry.c40
-rw-r--r--examples/sg_excl.c46
-rw-r--r--examples/sg_sat_chk_power.c5
-rw-r--r--examples/sg_sat_smart_rd_data.c5
-rw-r--r--examples/sg_simple1.c54
-rw-r--r--examples/sgq_dd.c59
6 files changed, 110 insertions, 99 deletions
diff --git a/examples/scsi_inquiry.c b/examples/scsi_inquiry.c
index 32fe74d6..99497490 100644
--- a/examples/scsi_inquiry.c
+++ b/examples/scsi_inquiry.c
@@ -1,3 +1,24 @@
+/*
+ * Copyright (C) 1999-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)
+ * any later version.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * Test code for D. Gilbert's extensions to the Linux OS SCSI generic ("sg")
+ * device driver.
+ * This program does a SCSI inquiry command on the given device and
+ * outputs some of the result. This program highlights the use of the
+ * SCSI_IOCTL_SEND_COMMAND ioctl. This should be able to be applied to
+ * any SCSI device file descriptor (not just one related to sg). [Whether
+ * this is a good idea on a disk while it is mounted is debatable.
+ * No detrimental effects when this was tested ...]
+ *
+ * Version 0.16 20181207
+ */
+
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
@@ -11,25 +32,6 @@
#include <scsi/scsi.h>
/* #include <scsi/scsi_ioctl.h> */ /* glibc hides this file sometimes */
-/* Test code for D. Gilbert's extensions to the Linux OS SCSI generic ("sg")
- device driver.
-* Copyright (C) 1999 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 does a SCSI inquiry command on the given device and
- outputs some of the result. This program highlights the use of the
- SCSI_IOCTL_SEND_COMMAND ioctl. This should be able to be applied to
- any SCSI device file descriptor (not just one related to sg). [Whether
- this is a good idea on a disk while it is mounted is debatable.
- No detrimental effects when this was tested ...]
-
-Version 0.15 20160528
-*/
-
-
typedef struct my_scsi_ioctl_command {
unsigned int inlen; /* _excluding_ scsi command length */
unsigned int outlen;
diff --git a/examples/sg_excl.c b/examples/sg_excl.c
index 8cbab750..38645252 100644
--- a/examples/sg_excl.c
+++ b/examples/sg_excl.c
@@ -1,3 +1,28 @@
+/*
+ * 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)
+ * any later version.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This is a simple program that tests the O_EXCL flag in sg while
+ * executing a SCSI INQUIRY command and a
+ * TEST UNIT READY command using the SCSI generic (sg) driver
+ *
+ * Invocation: sg_excl [-x] <sg_device>
+ *
+ * Version 3.61 (20181207)
+ *
+ * 6 byte INQUIRY command:
+ * [0x12][ |lu][pg cde][res ][al len][cntrl ]
+ *
+ * 6 byte TEST UNIT READY command:
+ * [0x00][ |lu][res ][res ][res ][res ]
+ *
+ */
+
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
@@ -11,27 +36,6 @@
#include "sg_lib.h"
#include "sg_io_linux.h"
-/* This is a simple program that tests the O_EXCL flag in sg while
- executing a SCSI INQUIRY command and a
- TEST UNIT READY command using the SCSI generic (sg) driver
-
-* 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)
-* any later version.
-
- Invocation: sg_excl [-x] <sg_device>
-
- Version 3.60 (20180220)
-
-6 byte INQUIRY command:
-[0x12][ |lu][pg cde][res ][al len][cntrl ]
-
-6 byte TEST UNIT READY command:
-[0x00][ |lu][res ][res ][res ][res ]
-
-*/
#define INQ_REPLY_LEN 96
#define INQ_CMD_LEN 6
diff --git a/examples/sg_sat_chk_power.c b/examples/sg_sat_chk_power.c
index b5ea18ae..ca24f665 100644
--- a/examples/sg_sat_chk_power.c
+++ b/examples/sg_sat_chk_power.c
@@ -10,8 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -25,6 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
+ * SPDX-License-Identifier: BSD-2-Clause
*/
#include <unistd.h>
@@ -59,7 +58,7 @@
#define EBUFF_SZ 256
-static const char * version_str = "1.07 20180706";
+static const char * version_str = "1.08 20181207";
#if 0
diff --git a/examples/sg_sat_smart_rd_data.c b/examples/sg_sat_smart_rd_data.c
index 1e7295d3..223da2a7 100644
--- a/examples/sg_sat_smart_rd_data.c
+++ b/examples/sg_sat_smart_rd_data.c
@@ -10,8 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -25,6 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
+ * SPDX-License-Identifier: BSD-2-Clause
*/
#include <unistd.h>
@@ -58,7 +57,7 @@
#define EBUFF_SZ 256
-static char * version_str = "1.04 20180220";
+static char * version_str = "1.05 20181207";
int main(int argc, char * argv[])
{
diff --git a/examples/sg_simple1.c b/examples/sg_simple1.c
index d8352678..b8ef3491 100644
--- a/examples/sg_simple1.c
+++ b/examples/sg_simple1.c
@@ -1,3 +1,32 @@
+/*
+ * Copyright (C) 1999-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)
+ * any later version.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This is a simple program executing a SCSI INQUIRY command and a
+ * TEST UNIT READY command using the SCSI generic (sg) driver
+ * There is another variant of this program called "sg_simple2"
+ * which does not include the sg_lib.h header and logic and so has
+ * simpler but more primitive error processing.
+ * In the lk 2.6 series devices nodes such as /dev/sda also support
+ * the SG_IO ioctl.
+ *
+ * Invocation: sg_simple1 [-x] <scsi_device>
+ *
+ * Version 3.60 (20181207)
+ *
+ * 6 byte INQUIRY command:
+ * [0x12][ |lu][pg cde][res ][al len][cntrl ]
+ *
+ * 6 byte TEST UNIT READY command:
+ * [0x00][ |lu][res ][res ][res ][res ]
+ *
+ */
+
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
@@ -10,31 +39,6 @@
#include "sg_lib.h"
#include "sg_io_linux.h"
-/* This is a simple program executing a SCSI INQUIRY command and a
- TEST UNIT READY command using the SCSI generic (sg) driver
- There is another variant of this program called "sg_simple2"
- which does not include the sg_lib.h header and logic and so has
- simpler but more primitive error processing.
- In the lk 2.6 series devices nodes such as /dev/sda also support
- the SG_IO ioctl.
-
-* Copyright (C) 1999-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.
-
- Invocation: sg_simple1 [-x] <scsi_device>
-
- Version 03.59 (20160528)
-
-6 byte INQUIRY command:
-[0x12][ |lu][pg cde][res ][al len][cntrl ]
-
-6 byte TEST UNIT READY command:
-[0x00][ |lu][res ][res ][res ][res ]
-
-*/
#define INQ_REPLY_LEN 96
#define INQ_CMD_LEN 6
diff --git a/examples/sgq_dd.c b/examples/sgq_dd.c
index debbe377..00a98aad 100644
--- a/examples/sgq_dd.c
+++ b/examples/sgq_dd.c
@@ -1,3 +1,32 @@
+/*
+ * A utility program for the Linux OS SCSI generic ("sg") device driver.
+ * 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)
+ * any later version.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This program is a specialization 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. Multipliers:
+ * 'c','C' *1 'b','B' *512 'k' *1024 'K' *1000
+ * 'm' *(1024^2) 'M' *(1000^2) 'g' *(1024^3) 'G' *(1000^3)
+ *
+ * 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 (16KB
+ * in this case) are transferred to or from the sg device in a single SCSI
+ * command.
+ *
+ * This version should compile with Linux sg drivers with version numbers
+ * >= 30000 . This version uses queuing within the Linux sg driver.
+ */
+
#define _XOPEN_SOURCE 500
#include <unistd.h>
@@ -23,34 +52,8 @@ typedef uint8_t u_char; /* horrible, for scsi.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-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)
-* any later version.
-
- This program is a specialization 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. Multipliers:
- 'c','C' *1 'b','B' *512 'k' *1024 'K' *1000
- 'm' *(1024^2) 'M' *(1000^2) 'g' *(1024^3) 'G' *(1000^3)
-
- 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 (16KB
- in this case) are transferred to or from the sg device in a single SCSI
- command.
-
- This version should compile with Linux sg drivers with version numbers
- >= 30000 . This version uses queuing within the Linux sg driver.
-
-*/
-
-static char * version_str = "0.61 20180627";
+
+static char * version_str = "0.62 20181207";
/* resurrected from "0.55 20020509" */
#define DEF_BLOCK_SIZE 512