sg_xcopy: more clean-up

git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@509 6180dd3e-e324-4e3e-922d-17de1ae2f315
diff --git a/ChangeLog b/ChangeLog
index d91a2e5..3ac8851 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,7 @@
 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.37 [20130818] [svn: r508]
+Changelog for sg3_utils-1.37 [20130819] [svn: r509]
   - sg_compare_and_write: fix wrprotect setting
   - sg_inq: fix referrals VPD page
     - dev_id VPD: T10 vendor id designator clean up
diff --git a/README b/README
index f22d264..e5151a2 100644
--- a/README
+++ b/README
@@ -391,4 +391,4 @@
 
 
 Douglas Gilbert
-18th August 2013
+19th August 2013
diff --git a/debian/changelog b/debian/changelog
index e9ea219..7726814 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@
 
   * New upstream version
 
- -- Douglas Gilbert <[email protected]>  Sun, 18 Aug 2013 21:00:00 -0400
+ -- Douglas Gilbert <[email protected]>  Mon, 19 Aug 2013 14:00:00 -0400
 
 sg3-utils (1.36-0.1) unstable; urgency=low
 
diff --git a/doc/sg_xcopy.8 b/doc/sg_xcopy.8
index 7ffdc0e..be6d69b 100644
--- a/doc/sg_xcopy.8
+++ b/doc/sg_xcopy.8
@@ -260,6 +260,11 @@
 partition indication (e.g. /dev/sdc2) is ignored. The user should set
 \fISKIP\fR,  \fISEEK\fR and \fICOUNT\fR with information obtained
 from a command like 'fdisk \-l \-u /dev/sdc' to account for partitions.
+.PP
+XCOPY (LID1) capability has been added to the ddpt utility which is in
+a package of the same name. The ddpt utility will run on other
+OSes (e.g. FreeBSD and Windows) while sg_xcopy only runs on Linux. Also
+ddpt permits the arguments to \fIibs=\fR and \fIibs=\fR to be different.
 .SH EXAMPLES
 Copy 2M of data from the start of one device to another:
 .PP
diff --git a/sg3_utils.spec b/sg3_utils.spec
index 8d3379a..910a88a 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -79,7 +79,7 @@
 %{_libdir}/*.la
 
 %changelog
-* Sun Aug 17 2013 - dgilbert at interlog dot com
+* Mon Aug 19 2013 - dgilbert at interlog dot com
 - track t10 changes
   * sg3_utils-1.37
 
diff --git a/src/sg_xcopy.c b/src/sg_xcopy.c
index f62b26e..306d7f1 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.38 20130817";
+static const char * version_str = "0.38 20130819";
 
 #define ME "sg_xcopy: "
 
@@ -597,8 +597,7 @@
     int seg_desc_len;
     int verb;
 
-    verb = verbose ? (verbose - 1) : 0;
-
+    verb = (verbose > 1) ? (verbose - 2) : 0;
     memset(xcopyBuff, 0, 256);
     xcopyBuff[0] = list_id;
     xcopyBuff[1] = (list_id_usage << 3) | priority;
@@ -613,10 +612,6 @@
                                         src_lba, dst_lba);
     xcopyBuff[11] = seg_desc_len; /* One segment descriptor */
     desc_offset += seg_desc_len;
-    if (verbose > 3) {
-        pr2serr("\nParameter list in hex (length %d):\n", desc_offset);
-        dStrHexErr((const char *)xcopyBuff, desc_offset, 1);
-    }
     /* set noisy so if a UA happens it will be printed to stderr */
     return sg_ll_extended_copy(sg_fd, xcopyBuff, desc_offset, 1, verb);
 }
@@ -1135,6 +1130,26 @@
          */
         pr2serr("      %s\n", (const char *)ip);
         break;
+    case 9: /* Protocol specific port identifier */
+        /* added in spc4r36, PIV must be set, proto_id indicates */
+        /* whether UAS (USB) or SOP (PCIe) or ... */
+        if (! piv)
+            pr2serr("      >>>> Protocol specific port identifier "
+                    "expects protocol\n"
+                    "           identifier to be valid and it is not\n");
+        if (TPROTO_UAS == p_id) {
+            pr2serr("      USB device address: 0x%x\n", 0x7f & ip[0]);
+            pr2serr("      USB interface number: 0x%x\n", ip[2]);
+        } else if (TPROTO_SOP == p_id) {
+            pr2serr("      PCIe routing ID, bus number: 0x%x\n", ip[0]);
+            pr2serr("          function number: 0x%x\n", ip[1]);
+            pr2serr("          [or device number: 0x%x, function number: "
+                    "0x%x]\n", (0x1f & (ip[1] >> 3)), 0x7 & ip[1]);
+        } else
+            pr2serr("      >>>> unexpected protocol indentifier: 0x%x\n"
+                    "           with Protocol specific port "
+                    "identifier\n", p_id);
+        break;
     default: /* reserved */
         pr2serr("      reserved designator=0x%x\n", desig_type);
         dStrHexErr((const char *)ip, i_len, 0);
@@ -1146,13 +1161,14 @@
 desc_from_vpd_id(int sg_fd, unsigned char *desc, int desc_len,
                  unsigned int block_size, int pad)
 {
-    int res;
+    int res, verb;
     unsigned char rcBuff[256], *ucp, *best = NULL;
     unsigned int len = 254;
     int off = -1, u, i_len, best_len = 0, assoc, desig, f_desig = 0;
 
+    verb = (verbose ? verbose - 1: 0);
     memset(rcBuff, 0xff, len);
-    res = sg_ll_inquiry(sg_fd, 0, 1, 0x83, rcBuff, 4, 1, verbose);
+    res = sg_ll_inquiry(sg_fd, 0, 1, 0x83, rcBuff, 4, 1, verb);
     if (0 != res) {
         pr2serr("VPD inquiry failed with %d\n", res);
         return res;
@@ -1161,7 +1177,7 @@
         return SG_LIB_CAT_MALFORMED;
     }
     len = ((rcBuff[2] << 8) + rcBuff[3]) + 4;
-    res = sg_ll_inquiry(sg_fd, 0, 1, 0x83, rcBuff, len, 1, verbose);
+    res = sg_ll_inquiry(sg_fd, 0, 1, 0x83, rcBuff, len, 1, verb);
     if (0 != res) {
         pr2serr("VPD inquiry failed with %d\n", res);
         return res;
@@ -1186,7 +1202,7 @@
         }
         assoc = ((ucp[1] >> 4) & 0x3);
         desig = (ucp[1] & 0xf);
-        if (verbose)
+        if (verbose > 2)
             pr2serr("    Desc %d: assoc %u desig %u len %d\n", off, assoc,
                     desig, i_len);
         /* Descriptor must be less than 16 bytes */