aboutsummaryrefslogtreecommitdiff
path: root/src/sg_xcopy.c
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2014-03-20 00:16:40 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2014-03-20 00:16:40 +0000
commit8554a0f7b7ae4bd5c9f6094b81202b6009b7c777 (patch)
tree4a3901248940e2702211725665a699681f3fc7ae /src/sg_xcopy.c
parent5ba2664a06e6b1b811174b043db1165026158b44 (diff)
downloadsg3_utils-8554a0f7b7ae4bd5c9f6094b81202b6009b7c777.tar.gz
sg_logs: placeholder for pending defects lpage; sg_unmap: fix another problem with --grpnum= option; sg_xcopy tweak
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@560 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src/sg_xcopy.c')
-rw-r--r--src/sg_xcopy.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/sg_xcopy.c b/src/sg_xcopy.c
index 7aaa2c91..42e23897 100644
--- a/src/sg_xcopy.c
+++ b/src/sg_xcopy.c
@@ -62,7 +62,7 @@
#include "sg_cmds_extra.h"
#include "sg_io_linux.h"
-static const char * version_str = "0.43 20140308";
+static const char * version_str = "0.44 20140312";
#define ME "sg_xcopy: "
@@ -308,6 +308,8 @@ find_bsg_major(void)
fclose(fp);
}
+/* Returns a file descriptor on success (0 or greater), -1 for an open
+ * error, -2 for a standard INQUIRY problem. */
static int
open_sg(struct xcopy_fp_t * fp, int verbose)
{
@@ -353,7 +355,7 @@ open_sg(struct xcopy_fp_t * fp, int verbose)
pr2serr("INQUIRY failed on %s\n", ebuff);
sg_cmds_close_device(fp->sg_fd);
fp->sg_fd = -1;
- return fp->sg_fd;
+ return -2;
}
fp->pdt = sir.peripheral_type;
@@ -1788,11 +1790,20 @@ main(int argc, char * argv[])
return SG_LIB_FILE_ERROR;
}
- if (open_sg(&ixcf, verbose) < 0)
- return SG_LIB_CAT_INVALID_OP;
-
- if (open_sg(&oxcf, verbose) < 0)
- return SG_LIB_CAT_INVALID_OP;
+ res = open_sg(&ixcf, verbose);
+ if (res < 0) {
+ if (-1 == res)
+ return SG_LIB_FILE_ERROR;
+ else
+ return SG_LIB_CAT_OTHER;
+ }
+ res = open_sg(&oxcf, verbose);
+ if (res < 0) {
+ if (-1 == res)
+ return SG_LIB_FILE_ERROR;
+ else
+ return SG_LIB_CAT_OTHER;
+ }
if ((STDIN_FILENO == infd) && (STDOUT_FILENO == outfd)) {
pr2serr("Can't have both 'if' as stdin _and_ 'of' as stdout\n");