add scripts/59-scsi-sg3_utils.rules: linux specific udev rules

git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@558 6180dd3e-e324-4e3e-922d-17de1ae2f315
diff --git a/ChangeLog b/ChangeLog
index 51007a9..ad9d3bd 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.38 [20140303] [svn: r557]
+Changelog for sg3_utils-1.38 [20140308] [svn: r558]
   - sg_ses: add --dev-slot-num= and --sas-addr=
     - fix --data=- problem with large buffers
     - new --data=@FN to read hex data from file FN
@@ -45,6 +45,7 @@
   - scripts/rescan-scsi-bus.sh: check if FC driver exports
     issue_lip before using it
     - man page added (Linux only)
+  - scripts/59-scsi-sg3_utils.rules: linux specific udev rules
   - examples: add sg_tst_excl3 for testing O_EXCL
     - improve sg_tst_excl and sg_tst_excl2
     - add sg_tst_context for testing file handle contexts
diff --git a/doc/sg_xcopy.8 b/doc/sg_xcopy.8
index 123816f..1dfdbae 100644
--- a/doc/sg_xcopy.8
+++ b/doc/sg_xcopy.8
@@ -1,4 +1,4 @@
-.TH SG_XCOPY "8" "December 2013" "sg3_utils\-1.38" SG3_UTILS
+.TH SG_XCOPY "8" "March 2014" "sg3_utils\-1.38" SG3_UTILS
 .SH NAME
 sg_xcopy \- copy data to and from files and devices using SCSI EXTENDED
 COPY (XCOPY)
@@ -41,6 +41,11 @@
 with the \fI\-\-on_src\fR or \fIiflag=xflag\R options which cause the XCOPY
 command to be sent to \fIIFILE\fR instead. Also see the section on
 ENVIRONMENT VARIABLES.
+.PP
+The ddpt utility supports the same xcopy(LID1) functionality as this utility
+with the same options and flags. Additionally ddpt supports a subset of
+xcopy(LID4) functionality variously called "xcopy version 2, lite" or ODX.
+ODX is a market name and stands for Offloaded Data Xfer (i.e. transfer).
 .SH OPTIONS
 .TP
 \fBbpt\fR=\fIBPT\fR
@@ -322,7 +327,7 @@
 .SH "REPORTING BUGS"
 Report bugs to <dgilbert at interlog dot com>.
 .SH COPYRIGHT
-Copyright \(co 2000\-2013 Hannes Reinecke and Douglas Gilbert
+Copyright \(co 2000\-2014 Hannes Reinecke and Douglas Gilbert
 .br
 This software is distributed under the GPL version 2. There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@@ -346,4 +351,4 @@
 .B sdparm(sdparm)
 .PP
 See also
-.B dd(1), sg_copy_results(sg3_utils), ddrescue(GNU), ddpt(ddpt)
+.B dd(1), sg_copy_results(sg3_utils), ddrescue(GNU), ddpt,ddptctl(ddpt)
diff --git a/scripts/59-scsi-sg3_utils.rules b/scripts/59-scsi-sg3_utils.rules
new file mode 100644
index 0000000..71a3df0
--- /dev/null
+++ b/scripts/59-scsi-sg3_utils.rules
@@ -0,0 +1,49 @@
+# SCSI-ID mappings for sg3_utils
+
+ACTION=="remove", GOTO="sg3_utils_end"
+
+SUBSYSTEM!="block", GOTO="sg3_utils_end"
+
+# Import values for partitions
+ENV{DEVTYPE}=="partition", IMPORT{parent}="SCSI_*", ENV{ID_SCSI}="1"
+# SCSI INQUIRY values
+KERNEL=="sd*[!0-9]|sr*", IMPORT{program}="/usr/bin/sg_inq --export $tempnode", ENV{ID_SCSI}="1"
+# scsi_id compat mappings
+ENV{SCSI_VENDOR}=="?*", ENV{ID_VENDOR}="$env{SCSI_VENDOR}"
+ENV{SCSI_VENDOR_ENC}=="?*", ENV{ID_VENDOR_ENC}="$env{SCSI_VENDOR_ENC}"
+ENV{SCSI_MODEL}=="?*", ENV{ID_MODEL}="$env{SCSI_MODEL}"
+ENV{SCSI_MODEL_ENC}=="?*", ENV{ID_MODEL_ENC}="$env{SCSI_MODEL_ENC}"
+ENV{SCSI_REVISION}=="?*", ENV{ID_REVISION}="$env{SCSI_REVISION}"
+ENV{SCSI_TYPE}=="?*", ENV{ID_TYPE}="$env{SCSI_TYPE}"
+# SCSI EVPD page 0x80 values
+KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI}=="1", IMPORT{program}="/usr/bin/sg_inq --export --page=sn $tempnode"
+ENV{SCSI_IDENT_SERIAL}=="?*", ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-id/scsi-S$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_SERIAL}"
+# SCSI EVPD page 0x83 values
+KERNEL=="sd*[!0-9]|sr*", ENV{ID_SCSI}=="1", IMPORT{program}="/usr/bin/sg_inq --export --page=di $tempnode"
+# Select which identifier to use per default
+# 1: NAA identifier (prefix 3)
+ENV{SCSI_IDENT_LUN_NAA}=="?*", ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-id/scsi-3$env{SCSI_IDENT_LUN_NAA}"
+ENV{SCSI_IDENT_LUN_NAA}=="?*", ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-id/scsi-3$env{SCSI_IDENT_LUN_NAA}-part%n"
+ENV{SCSI_IDENT_LUN_NAA}=="?*", ENV{ID_WWN}!="?*", ENV{ID_WWN}="0x$env{SCSI_IDENT_LUN_NAA}"
+ENV{SCSI_IDENT_LUN_NAA}=="?*", ENV{ID_WWN_WITH_EXTENSION}!="?*", ENV{ID_WWN_WITH_EXTENSION}="0x$env{SCSI_IDENT_LUN_NAA}"
+# 2: EUI-64 identifer (prefix 2)
+ENV{SCSI_IDENT_LUN_EUI64}=="?*", ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-id/scsi-2$env{SCSI_IDENT_LUN_EUI64}"
+ENV{SCSI_IDENT_LUN_EUI64}=="?*", ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-id/scsi-2$env{SCSI_IDENT_LUN_EUI64}-part%n"
+# 3: SCSI name identifier (prefix 8)
+ENV{SCSI_IDENT_LUN_NAME}=="?*", ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-id/scsi-8$env{SCSI_IDENT_LUN_NAME}"
+ENV{SCSI_IDENT_LUN_NAME}=="?*", ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-id/scsi-8$env{SCSI_IDENT_LUN_NAME}-part%n"
+# 4: T10 Vendor identifer (prefix 1)
+ENV{SCSI_IDENT_LUN_T10}=="?*", ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-id/scsi-1$env{SCSI_IDENT_LUN_T10}"
+ENV{SCSI_IDENT_LUN_T10}=="?*", ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-id/scsi-1$env{SCSI_IDENT_LUN_T10}-part%n"
+# 5: Vendor-specific identifier (prefix 0)
+ENV{SCSI_IDENT_LUN_VENDOR}=="?*", ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-id/scsi-0$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_LUN_VENDOR}"
+ENV{SCSI_IDENT_LUN_VENDOR}=="?*", ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-id/scsi-0$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_LUN_VENDOR}-part%n"
+# ata_id compability
+ENV{ID_SERIAL}!="?*", ENV{SCSI_VENDOR}=="ATA", ENV{ID_BUS}="ata", ENV{ID_ATA}="1", ENV{ID_SERIAL}="$env{SCSI_MODEL}_$env{SCSI_IDENT_LUN_VENDOR}"
+# Compat ID_SERIAL setting
+ENV{ID_SERIAL}!="?*", ENV{SCSI_IDENT_LUN_NAA}=="?*", ENV{ID_BUS}="scsi", ENV{ID_SERIAL}="3$env{SCSI_IDENT_LUN_NAA}", ENV{ID_SERIAL_SHORT}="$env{SCSI_IDENT_LUN_NAA}"
+ENV{ID_SERIAL}!="?*", ENV{SCSI_IDENT_LUN_EUI64}=="?*", ENV{ID_BUS}="scsi", ENV{ID_SERIAL}="2$env{SCSI_IDENT_LUN_EUI64}", ENV{ID_SERIAL_SHORT}="$env{SCSI_IDENT_LUN_EUI64}"
+ENV{ID_SERIAL}!="?*", ENV{SCSI_IDENT_LUN_NAME}=="?*", ENV{ID_BUS}="scsi", ENV{ID_SERIAL}="8$env{SCSI_IDENT_LUN_NAME}", ENV{ID_SERIAL_SHORT}="$env{SCSI_IDENT_LUN_NAME}"
+ENV{ID_SERIAL}!="?*", ENV{SCSI_IDENT_LUN_T10}=="?*", ENV{ID_BUS}="scsi", ENV{ID_SERIAL}="1$env{SCSI_IDENT_LUN_T10}", ENV{ID_SERIAL_SHORT}="$env{SCSI_IDENT_LUN_T10}"
+ENV{ID_SERIAL}!="?*", ENV{SCSI_IDENT_LUN_VENDOR}=="?*", ENV{ID_BUS}="scsi", ENV{ID_SERIAL}="0$env{SCSI_VENDOR}_$env{SCSI_MODEL}_$env{SCSI_IDENT_LUN_VENDOR}", ENV{ID_SERIAL_SHORT}="$env{SCSI_IDENT_LUN_VENDOR}"
+LABEL="sg3_utils_end"
diff --git a/scripts/README b/scripts/README
index a1402b2..082e0e6 100644
--- a/scripts/README
+++ b/scripts/README
@@ -48,5 +48,9 @@
 script. Since it depends on the sdparm utility it has been moved to
 the sdparm package in its scripts directory.
 
+59-scsi-sg3_utils.rules is a Linux specific file for udev. These rules use
+'sg_inq --export' to help udev create identifying device nodes, for example
+/dev/disk/by-id/wwn-0x5001501234567890-part1.
+
 Douglas Gilbert
-9th January 2013
+8th March 2014
diff --git a/src/sg_copy_results.c b/src/sg_copy_results.c
index 1a1c0f3..cc3e3ce 100644
--- a/src/sg_copy_results.c
+++ b/src/sg_copy_results.c
@@ -35,7 +35,7 @@
    and the optional list identifier passed as the list_id argument.
 */
 
-static const char * version_str = "1.7 20140123";
+static const char * version_str = "1.8 20140308";
 
 
 #define MAX_XFER_LEN 10000
@@ -286,7 +286,7 @@
           "sg_copy_results [--failed|--params|--receive|--status] [--help]\n"
           "                       [--hex] [--list_id=ID] [--verbose] "
           "[--version]\n"
-          "                       DEVICE\n"
+          "                       [--xfer_len=BTL] DEVICE\n"
           "  where:\n"
           "    --failed|-f          use FAILED SEGMENT DETAILS service "
           "action\n"
diff --git a/src/sg_xcopy.c b/src/sg_xcopy.c
index e27b02e..7aaa2c9 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.42 20140123";
+static const char * version_str = "0.43 20140308";
 
 #define ME "sg_xcopy: "
 
@@ -566,8 +566,8 @@
             "    --verbose   same action as verbose=1\n"
             "    --version   print version information then exit\n\n"
             "Copy from IFILE to OFILE, similar to dd command; "
-            "but using the SCSI\nEXTENDED COPY (XCOPY) command. For list "
-            "of flags, use '-hh'.\n");
+            "but using the SCSI\nEXTENDED COPY (XCOPY(LID1)) command. For "
+            "list of flags, use '-hh'.\n");
     return;
 
 secondary_help: