aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--doc/sg_get_config.816
-rw-r--r--doc/sg_raw.88
-rw-r--r--doc/sg_read_long.86
-rw-r--r--doc/sg_rmsn.813
-rw-r--r--doc/sg_start.84
-rw-r--r--doc/sg_verify.812
-rw-r--r--src/sg_get_config.c21
-rw-r--r--src/sg_rmsn.c20
-rw-r--r--src/sg_verify.c18
10 files changed, 81 insertions, 40 deletions
diff --git a/ChangeLog b/ChangeLog
index 9dfc827a..c021aca2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,10 +2,11 @@ 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.31 [20110206] [svn: r377]
+Changelog for sg3_utils-1.31 [20110206] [svn: r378]
- sg_decode_sense: new utility to decode sense data
- sg_vpd: LB provisioning + Block limits pages (sbc3r26)
- sync asc/ascq and version descriptors with spc4r28
+ - sg_get_config, sg_rmsn, sg_verify: add --readonly option
- sg_lib: implement forwarded sense data descriptor
- sg_lib, sg_turs, sg_format: more precision for progress
indication (two places after decimal point)
diff --git a/doc/sg_get_config.8 b/doc/sg_get_config.8
index 38e550e2..2dde6a5b 100644
--- a/doc/sg_get_config.8
+++ b/doc/sg_get_config.8
@@ -1,12 +1,12 @@
-.TH SG_GET_CONFIG "8" "November 2008" "sg3_utils\-1.27" SG3_UTILS
+.TH SG_GET_CONFIG "8" "February 2011" "sg3_utils\-1.31" SG3_UTILS
.SH NAME
sg_get_config \- sends a SCSI GET CONFIGURATION command (MMC-4 +)
.SH SYNOPSIS
.B sg_get_config
[\fI\-\-brief\fR] [\fI\-\-current\fR] [\fI\-\-help\fR] [\fI\-\-hex\fR]
-[\fI\-\-inner\-hex\fR] [\fI\-\-list\fR] [\fI\-\-raw\fR] [\fI\-\-rt=RT\fR]
-[\fI\-\-starting=FC\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR]
-\fIDEVICE\fR
+[\fI\-\-inner\-hex\fR] [\fI\-\-list\fR] [\fI\-\-raw\fR] [\fI\-\-readonly\fR]
+[\fI\-\-rt=RT\fR] [\fI\-\-starting=FC\fR] [\fI\-\-verbose\fR]
+[\fI\-\-version\fR] \fIDEVICE\fR
.SH DESCRIPTION
.\" Add any additional description here
.PP
@@ -58,6 +58,12 @@ Simply lists the feature names and profiles (followed by their hex values)
that this utility knows about. If \fI\-\-brief\fR is also given then only
feature names are listed.
.TP
+\fB\-q\fR, \fB\-\-readonly\fR
+opens the DEVICE read\-only rather than read\-write which is the
+default. The Linux sg driver needs read\-write access for the SCSI
+GET CONFIGURATION command but other access methods may require
+read\-only access.
+.TP
\fB\-r\fR, \fB\-\-rt\fR=\fIRT\fR
where \fIRT\fR is the field of that name in the GET CONFIGURATION cdb.
Allowable values are 0, 1, 2, or 3 . The command's action also depends on
@@ -127,7 +133,7 @@ Written by Douglas Gilbert.
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
-Copyright \(co 2004\-2008 Douglas Gilbert
+Copyright \(co 2004\-2011 Douglas Gilbert
.br
This software is distributed under a FreeBSD license. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/doc/sg_raw.8 b/doc/sg_raw.8
index be3d8266..37fb69b5 100644
--- a/doc/sg_raw.8
+++ b/doc/sg_raw.8
@@ -1,4 +1,4 @@
-.TH SG_RAW "8" "December 2010" "sg3_utils\-1.31" SG3_UTILS
+.TH SG_RAW "8" "February 2011" "sg3_utils\-1.31" SG3_UTILS
.SH NAME
sg_raw \- sends an arbitrary SCSI command to a device
.SH SYNOPSIS
@@ -50,8 +50,8 @@ Expect to receive up to \fIRLEN\fR bytes of data from the \fIDEVICE\fR.
of bytes.
.TP
\fB\-R\fR, \fB\-\-readonly\fR
-Open \fIDEVICE\fR read-only. The default (without this option) is to open
-it read-write.
+Open \fIDEVICE\fR read\-only. The default (without this option) is to open
+it read\-write.
.TP
\fB\-s\fR, \fB\-\-send\fR=\fISLEN\fR
Read \fISLEN\fR bytes of data, either from stdin or from a file, and send
@@ -125,7 +125,7 @@ Written by Ingo van Lil
.SH "REPORTING BUGS"
Report bugs to <inguin at gmx dot de>.
.SH COPYRIGHT
-Copyright \(co 2001\-2010 Ingo van Lil
+Copyright \(co 2001\-201q Ingo van Lil
.br
This software is distributed under the GPL version 2. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/doc/sg_read_long.8 b/doc/sg_read_long.8
index ea2db059..4c4a3823 100644
--- a/doc/sg_read_long.8
+++ b/doc/sg_read_long.8
@@ -50,9 +50,9 @@ address is read. The default is to leave the 'PBLOCK' bit clear in
which case the logical block (plus any ECC data) is read.
.TP
\fB\-r\fR, \fB\-\-readonly\fR
-opens the DEVICE read-only rather than read-write which is the
-default. The Linux sg driver needs read-write access for the SCSI
-READ LONG command but other access methods may require read-only
+opens the DEVICE read\-only rather than read\-write which is the
+default. The Linux sg driver needs read\-write access for the SCSI
+READ LONG command but other access methods may require read\-only
access.
.TP
\fB\-v\fR, \fB\-\-verbose\fR
diff --git a/doc/sg_rmsn.8 b/doc/sg_rmsn.8
index d318ba7d..94978131 100644
--- a/doc/sg_rmsn.8
+++ b/doc/sg_rmsn.8
@@ -1,9 +1,10 @@
-.TH SG_RMSN "8" "April 2008" "sg3_utils\-1.26" SG3_UTILS
+.TH SG_RMSN "8" "February 2011" "sg3_utils\-1.31" SG3_UTILS
.SH NAME
sg_rmsn \- sends a SCSI READ MEDIA SERIAL NUMBER command
.SH SYNOPSIS
.B sg_rmsn
-[\fI\-\-help\fR] [\fI\-\-raw\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR]
+[\fI\-\-help\fR] [\fI\-\-raw\fR] [\fI\-\-readonly\fR] [\fI\-\-verbose\fR]
+[\fI\-\-version\fR]
\fIDEVICE\fR
.SH DESCRIPTION
.\" Add any additional description here
@@ -27,6 +28,12 @@ at the end so its length is a multiple of 4). The default action is
to print the serial number out in ASCII\-HEX with ASCII characters to
the right. All error messages are sent to stderr.
.TP
+\fB\-R\fR, \fB\-\-readonly\fR
+opens the DEVICE read\-only rather than read\-write which is the
+default. The Linux sg driver needs read\-write access for the SCSI
+READ MEDIA SERIAL NUMBER command but other access methods may require
+read\-only access.
+.TP
\fB\-v\fR, \fB\-\-verbose\fR
increase the level of verbosity, (i.e. debug output).
.TP
@@ -49,7 +56,7 @@ Written by Douglas Gilbert.
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
-Copyright \(co 2005\-2008 Douglas Gilbert
+Copyright \(co 2005\-2011 Douglas Gilbert
.br
This software is distributed under a FreeBSD license. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/doc/sg_start.8 b/doc/sg_start.8
index f734762c..499a2a01 100644
--- a/doc/sg_start.8
+++ b/doc/sg_start.8
@@ -1,4 +1,4 @@
-.TH SG_START "8" "January 2011" "sg3_utils\-1.31" SG3_UTILS
+.TH SG_START "8" "February 2011" "sg3_utils\-1.31" SG3_UTILS
.SH NAME
sg_start \- send SCSI START STOP UNIT command to start, stop, load or
eject medium
@@ -105,7 +105,7 @@ FORCE_IDLE_0 (SBC) and 0xb (decimal 11) for FORCE_STANDBY_0 (SBC). See recent
SBC\-3, MMC\-5 and SAS drafts at www.t10.org for more information.
.TP
\fB\-r\fR, \fB\-\-readonly\fR
-open the \fIDEVICE\fR in read-only mode. Maybe required in Linux to stop a
+open the \fIDEVICE\fR in read\-only mode. Maybe required in Linux to stop a
nuisance spin\-up if the \fIDEVICE\fR is an ATA disk. The nuisance spin\-up
may occur at the end of this command negating the effect of the
\fI\-\-stop\fR option.
diff --git a/doc/sg_verify.8 b/doc/sg_verify.8
index 441ff47e..7ff38488 100644
--- a/doc/sg_verify.8
+++ b/doc/sg_verify.8
@@ -1,11 +1,11 @@
-.TH SG_VERIFY "8" "March 2009" "sg3_utils\-1.27" SG3_UTILS
+.TH SG_VERIFY "8" "February 2011" "sg3_utils\-1.31" SG3_UTILS
.SH NAME
sg_verify \- invoke SCSI VERIFY command(s) on a block device
.SH SYNOPSIS
.B sg_verify
[\fI\-\-bpc=BPC\fR] [\fI\-\-count=COUNT\fR] [\fI\-\-dpo\fR] [\fI\-\-help\fR]
-[\fI\-\-lba=LBA\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR]
-[\fI\-\-vrprotect=VRP\fR] \fIDEVICE\fR
+[\fI\-\-lba=LBA\fR] [\fI\-\-readonly\fR] [\fI\-\-verbose\fR]
+[\fI\-\-version\fR] [\fI\-\-vrprotect=VRP\fR] \fIDEVICE\fR
.SH DESCRIPTION
.\" Add any additional description here
.PP
@@ -51,6 +51,10 @@ where \fILBA\fR specifies the logical block address of the first block to
start the verify operation. \fILBA\fR is assumed to be decimal unless prefixed
by '0x' or a trailing 'h' (see below). The default value is 0 (i.e. the start
of the device).
+\fB\-r\fR, \fB\-\-readonly\fR
+opens the DEVICE read\-only rather than read\-write which is the
+default. The Linux sg driver needs read\-write access for the SCSI
+VERIFY command but other access methods may require read\-only access.
.TP
\fB\-v\fR, \fB\-\-verbose\fR
increase the level of verbosity, (i.e. debug output).
@@ -85,7 +89,7 @@ Written by Douglas Gilbert.
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
-Copyright \(co 2004\-2009 Douglas Gilbert
+Copyright \(co 2004\-2011 Douglas Gilbert
.br
This software is distributed under a FreeBSD license. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/src/sg_get_config.c b/src/sg_get_config.c
index d200448b..ef68de8b 100644
--- a/src/sg_get_config.c
+++ b/src/sg_get_config.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2010 Douglas Gilbert.
+ * Copyright (c) 2004-2011 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
@@ -27,7 +27,7 @@
*/
-static char * version_str = "0.36 20100312"; /* mmc6r02 */
+static char * version_str = "0.37 20110206"; /* mmc6r02 */
#define MX_ALLOC_LEN 8192
#define NAME_BUFF_SZ 64
@@ -45,6 +45,7 @@ static struct option long_options[] = {
{"inner-hex", 0, 0, 'i'},
{"list", 0, 0, 'l'},
{"raw", 0, 0, 'R'},
+ {"readonly", 0, 0, 'q'},
{"rt", 1, 0, 'r'},
{"starting", 1, 0, 's'},
{"verbose", 0, 0, 'v'},
@@ -59,9 +60,9 @@ usage()
fprintf(stderr,
"Usage: sg_get_config [--brief] [--current] [--help] [--hex] "
"[--inner-hex]\n"
- " [--list] [--raw] [--rt=RT] "
- "[--starting=FC]\n"
- " [--verbose] [--version] DEVICE\n"
+ " [--list] [--raw] [--readonly] [--rt=RT]\n"
+ " [--starting=FC] [--verbose] [--version] "
+ "DEVICE\n"
" where:\n"
" --brief|-b only give feature names of DEVICE "
"(don't decode)\n"
@@ -74,6 +75,8 @@ usage()
" --list|-l list all known features + profiles "
"(ignore DEVICE)\n"
" --raw|-R output in binary (to stdout)\n"
+ " --readonly|-q open DEVICE read-only (def: open it "
+ "read-write)\n"
" --rt=RT|-r RT default value is 0\n"
" 0 -> all feature descriptors (regardless "
"of currency)\n"
@@ -951,6 +954,7 @@ main(int argc, char * argv[])
int inner_hex = 0;
int list = 0;
int do_raw = 0;
+ int readonly = 0;
int rt = 0;
int starting = 0;
int verbose = 0;
@@ -963,7 +967,7 @@ main(int argc, char * argv[])
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "bchHilr:Rs:vV", long_options,
+ c = getopt_long(argc, argv, "bchHilqr:Rs:vV", long_options,
&option_index);
if (c == -1)
break;
@@ -988,6 +992,9 @@ main(int argc, char * argv[])
case 'l':
list = 1;
break;
+ case 'q':
+ ++readonly;
+ break;
case 'r':
rt = sg_get_num(optarg);
if ((rt < 0) || (rt > 3)) {
@@ -1064,7 +1071,7 @@ main(int argc, char * argv[])
}
sg_cmds_close_device(sg_fd);
- sg_fd = sg_cmds_open_device(device_name, 0 /* rw */, verbose);
+ sg_fd = sg_cmds_open_device(device_name, readonly, verbose);
if (sg_fd < 0) {
fprintf(stderr, ME "open error (rw): %s\n", safe_strerror(-sg_fd));
return SG_LIB_FILE_ERROR;
diff --git a/src/sg_rmsn.c b/src/sg_rmsn.c
index bebd42a4..25ca4800 100644
--- a/src/sg_rmsn.c
+++ b/src/sg_rmsn.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005-2010 Douglas Gilbert.
+ * Copyright (c) 2005-2011 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
@@ -26,7 +26,7 @@
* to the given SCSI device.
*/
-static char * version_str = "1.08 20100312";
+static char * version_str = "1.09 20110206";
#define SERIAL_NUM_SANITY_LEN (16 * 1024)
@@ -34,6 +34,7 @@ static char * version_str = "1.08 20100312";
static struct option long_options[] = {
{"help", 0, 0, 'h'},
{"raw", 0, 0, 'r'},
+ {"readonly", 0, 0, 'R'},
{"verbose", 0, 0, 'v'},
{"version", 0, 0, 'V'},
{0, 0, 0, 0},
@@ -42,11 +43,14 @@ static struct option long_options[] = {
static void usage()
{
fprintf(stderr, "Usage: "
- "sg_rmsn [--help] [--raw] [--verbose] [--version] DEVICE\n"
+ "sg_rmsn [--help] [--raw] [--readonly] [--verbose] [--version]\n"
+ " DEVICE\n"
" where:\n"
" --help|-h print out usage message\n"
" --raw|-r output serial number to stdout "
"(potentially binary)\n"
+ " --readonly|-R open DEVICE read-only (def: open it "
+ "read-write)\n"
" --verbose|-v increase verbosity\n"
" --version|-V print version string and exit\n\n"
"Performs a SCSI READ MEDIA SERIAL NUMBER command\n"
@@ -59,6 +63,7 @@ int main(int argc, char * argv[])
unsigned char rmsn_buff[4];
unsigned char * ucp = NULL;
int raw = 0;
+ int readonly = 0;
int verbose = 0;
const char * device_name = NULL;
int ret = 0;
@@ -66,7 +71,7 @@ int main(int argc, char * argv[])
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "hrvV", long_options,
+ c = getopt_long(argc, argv, "hrRvV", long_options,
&option_index);
if (c == -1)
break;
@@ -77,7 +82,10 @@ int main(int argc, char * argv[])
usage();
return 0;
case 'r':
- raw = 1;
+ ++raw;
+ break;
+ case 'R':
+ ++readonly;
break;
case 'v':
++verbose;
@@ -117,7 +125,7 @@ int main(int argc, char * argv[])
}
}
- sg_fd = sg_cmds_open_device(device_name, 0 /* rw */, verbose);
+ sg_fd = sg_cmds_open_device(device_name, readonly, verbose);
if (sg_fd < 0) {
fprintf(stderr, "open error: %s: %s\n", device_name,
safe_strerror(-sg_fd));
diff --git a/src/sg_verify.c b/src/sg_verify.c
index 0ae803e8..fae9e859 100644
--- a/src/sg_verify.c
+++ b/src/sg_verify.c
@@ -26,7 +26,7 @@
* This program issues the SCSI VERIFY command to the given SCSI block device.
*/
-static char * version_str = "1.14 20110206";
+static char * version_str = "1.15 20110206";
#define ME "sg_verify: "
@@ -37,6 +37,7 @@ static struct option long_options[] = {
{"dpo", 0, 0, 'd'},
{"help", 0, 0, 'h'},
{"lba", 1, 0, 'l'},
+ {"readonly", 0, 0, 'r'},
{"verbose", 0, 0, 'v'},
{"version", 0, 0, 'V'},
{"vrprotect", 1, 0, 'P'},
@@ -49,8 +50,9 @@ usage()
fprintf(stderr, "Usage: "
"sg_verify [--bpc=BPC] [--count=COUNT] [--dpo] [--help] "
"[--lba=LBA]\n"
- " [--verbose] [--version] [--vrprotect=VRP] "
- "DEVICE\n"
+ " [--readonly] [--verbose] [--version] "
+ "[--vrprotect=VRP]\n"
+ " DEVICE\n"
" where:\n"
" --bpc=BPC|-b BPC max blocks per verify command "
"(def 128)\n"
@@ -61,6 +63,8 @@ usage()
" --help|-h print out usage message\n"
" --lba=LBA|-l LBA logical block address to start "
"verify (def 0)\n"
+ " --readonly|-r open DEVICE read-only (def: open it "
+ "read-write)\n"
" --verbose|-v increase verbosity\n"
" --version|-V print version string and exit\n"
" --vrprotect=VRP|-P VRP set vrprotect field to VRP "
@@ -82,6 +86,7 @@ main(int argc, char * argv[])
int bpc = 128;
uint64_t lba = 0;
uint64_t orig_lba;
+ int readonly = 0;
int verbose = 0;
const char * device_name = NULL;
int ret = 0;
@@ -90,7 +95,7 @@ main(int argc, char * argv[])
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "b:c:dhl:P:vV", long_options,
+ c = getopt_long(argc, argv, "b:c:dhl:P:rvV", long_options,
&option_index);
if (c == -1)
break;
@@ -137,6 +142,9 @@ main(int argc, char * argv[])
return SG_LIB_SYNTAX_ERROR;
}
break;
+ case 'r':
+ ++readonly;
+ break;
case 'v':
++verbose;
break;
@@ -180,7 +188,7 @@ main(int argc, char * argv[])
usage();
return SG_LIB_SYNTAX_ERROR;
}
- sg_fd = sg_cmds_open_device(device_name, 0 /* rw */, verbose);
+ sg_fd = sg_cmds_open_device(device_name, readonly, verbose);
if (sg_fd < 0) {
fprintf(stderr, ME "open error: %s: %s\n", device_name,
safe_strerror(-sg_fd));