aboutsummaryrefslogtreecommitdiff
path: root/src/sg_get_lba_status.c
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2014-05-12 18:11:45 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2014-05-12 18:11:45 +0000
commit6f08d95bf0f49a3430ba6d3ac06c3f8b51b4d8d2 (patch)
treea51b893d2571fe82df396dacd82cb575d105cfd4 /src/sg_get_lba_status.c
parent7c5eb1f951e4349bef24fe9056fdc6c190217d95 (diff)
downloadsg3_utils-6f08d95bf0f49a3430ba6d3ac06c3f8b51b4d8d2.tar.gz
change SG_PERSIST_O_RDONLY to SG_PERSIST_IN_RDONLY; more --readonly options; windows work
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@574 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src/sg_get_lba_status.c')
-rw-r--r--src/sg_get_lba_status.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/sg_get_lba_status.c b/src/sg_get_lba_status.c
index 01969efa..61e47d17 100644
--- a/src/sg_get_lba_status.c
+++ b/src/sg_get_lba_status.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009-2013 Douglas Gilbert.
+ * Copyright (c) 2009-2014 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.
@@ -28,7 +28,7 @@
* device.
*/
-static const char * version_str = "1.05 20130507"; /* sbc2r29 */
+static const char * version_str = "1.06 20140512"; /* sbc2r29 */
#define MAX_GLBAS_BUFF_LEN (1024 * 1024)
#define DEF_GLBAS_BUFF_LEN 24
@@ -44,6 +44,7 @@ static struct option long_options[] = {
{"lba", required_argument, 0, 'l'},
{"maxlen", required_argument, 0, 'm'},
{"raw", no_argument, 0, 'r'},
+ {"readonly", no_argument, 0, 'R'},
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
{0, 0, 0, 0},
@@ -54,9 +55,9 @@ usage()
{
fprintf(stderr, "Usage: "
"sg_get_lba_status [--brief] [--help] [--hex] [--lba=LBA]\n"
- " [--maxlen=LEN] [--raw] [--verbose] "
- "[--version]\n"
- " DEVICE\n"
+ " [--maxlen=LEN] [--raw] [--readonly] "
+ "[--verbose]\n"
+ " [--version] DEVICE\n"
" where:\n"
" --brief|-b a descriptor per line: "
"<lba_hex blocks_hex p_status>\n"
@@ -72,6 +73,7 @@ usage()
DEF_GLBAS_BUFF_LEN );
fprintf(stderr,
" --raw|-r output in binary\n"
+ " --readonly|-R open DEVICE read-only (def: read-write)\n"
" --verbose|-v increase verbosity\n"
" --version|-V print version string and exit\n\n"
"Performs a SCSI GET LBA STATUS command (SBC-3)\n"
@@ -132,6 +134,7 @@ main(int argc, char * argv[])
uint32_t d_blocks = 0;
int maxlen = DEF_GLBAS_BUFF_LEN;
int do_raw = 0;
+ int o_readonly = 0;
int verbose = 0;
const char * device_name = NULL;
const unsigned char * ucp;
@@ -140,7 +143,7 @@ main(int argc, char * argv[])
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "bhHl:m:rvV", long_options,
+ c = getopt_long(argc, argv, "bhHl:m:rRvV", long_options,
&option_index);
if (c == -1)
break;
@@ -175,6 +178,9 @@ main(int argc, char * argv[])
case 'r':
++do_raw;
break;
+ case 'R':
+ ++o_readonly;
+ break;
case 'v':
++verbose;
break;
@@ -221,7 +227,7 @@ main(int argc, char * argv[])
}
}
- sg_fd = sg_cmds_open_device(device_name, 0 /* rw */, verbose);
+ sg_fd = sg_cmds_open_device(device_name, o_readonly, verbose);
if (sg_fd < 0) {
fprintf(stderr, "open error: %s: %s\n", device_name,
safe_strerror(-sg_fd));