aboutsummaryrefslogtreecommitdiff
path: root/src/sg_persist.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_persist.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_persist.c')
-rw-r--r--src/sg_persist.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/sg_persist.c b/src/sg_persist.c
index ca6eb874..5c30e8de 100644
--- a/src/sg_persist.c
+++ b/src/sg_persist.c
@@ -27,7 +27,7 @@
#include "sg_cmds_basic.h"
#include "sg_cmds_extra.h"
-static const char * version_str = "0.47 20140504";
+static const char * version_str = "0.48 20140511";
#define PRIN_RKEY_SA 0x0
@@ -47,7 +47,7 @@ static const char * version_str = "0.47 20140504";
#define MX_TIDS 32
#define MX_TID_LEN 256
-#define SG_PERSIST_O_RDONLY "SG_PERSIST_O_RDONLY"
+#define SG_PERSIST_IN_RDONLY "SG_PERSIST_IN_RDONLY"
struct opts_t {
unsigned int prout_type;
@@ -1044,9 +1044,6 @@ main(int argc, char * argv[])
op->prout_sa = -1;
op->inquiry = 1;
op->alloc_len = MX_ALLOC_LEN;
- cp = getenv(SG_PERSIST_O_RDONLY);
- if (cp)
- op->readonly = 1;
while (1) {
int option_index = 0;
@@ -1307,6 +1304,12 @@ main(int argc, char * argv[])
sg_cmds_close_device(sg_fd);
}
+ if (0 == op->readonly) {
+ cp = getenv(SG_PERSIST_IN_RDONLY);
+ if (cp && op->prin)
+ op->readonly = 1;
+ } else if (op->readonly > 1) /* -yy forces open(RW) */
+ op->readonly = 0;
if ((sg_fd = sg_cmds_open_device(device_name, op->readonly,
op->verbose)) < 0) {
pr2serr("sg_persist: error opening file (rw): %s: %s\n", device_name,