@@ -1029,6 +1029,8 @@
struct sg_simple_inquiry_resp inq_resp;
const char * cp;
struct opts_t opts;
+ int omode = 0;
+ const char *omode_desc = "rw";
memset(&opts, 0, sizeof(opts));
opts.prin = 1;
@@ -1292,10 +1294,17 @@
sg_cmds_close_device(sg_fd);
}
- if ((sg_fd = sg_cmds_open_device(device_name, 0 /* rw */,
+#ifdef SG_LIB_LINUX
+ if (opts.prin) {
+ omode = 1;
+ omode_desc = "ro";
+ }
+#endif
+
+ if ((sg_fd = sg_cmds_open_device(device_name, omode,
opts.verbose)) < 0) {
- pr2serr("sg_persist: error opening file (rw): %s: %s\n",
device_name,
- safe_strerror(-sg_fd));
+ pr2serr("sg_persist: error opening file (%s): %s: %s\n",
omode_desc,
+ device_name, safe_strerror(-sg_fd));
return SG_LIB_FILE_ERROR;