aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2018-01-09 03:09:10 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2018-01-09 03:09:10 +0000
commit605b21190ce9af77ee3533e12b2e59a7f883ffee (patch)
treebec664a8f7fde19b399af40a4be20a6d3c18b6b8 /lib
parenta0df198b498b114e901cb022acddcc14330275da (diff)
downloadsg3_utils-605b21190ce9af77ee3533e12b2e59a7f883ffee.tar.gz
FreeBSD port now works with NVMe SNTL and sg3_ses pass-through (NVME-MI); man page cleanups; improve SNTL translation to VPD page 0x83
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@743 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'lib')
-rw-r--r--lib/sg_cmds_basic.c13
-rw-r--r--lib/sg_cmds_basic2.c11
-rw-r--r--lib/sg_cmds_extra.c10
-rw-r--r--lib/sg_cmds_mmc.c10
-rw-r--r--lib/sg_io_linux.c2
-rw-r--r--lib/sg_lib.c8
-rw-r--r--lib/sg_lib_data.c10
-rw-r--r--lib/sg_pt_common.c124
-rw-r--r--lib/sg_pt_freebsd.c80
-rw-r--r--lib/sg_pt_linux.c4
-rw-r--r--lib/sg_pt_linux_nvme.c60
-rw-r--r--lib/sg_pt_solaris.c10
-rw-r--r--lib/sg_pt_win32.c11
13 files changed, 254 insertions, 99 deletions
diff --git a/lib/sg_cmds_basic.c b/lib/sg_cmds_basic.c
index 43f17968..479d45b3 100644
--- a/lib/sg_cmds_basic.c
+++ b/lib/sg_cmds_basic.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999-2017 Douglas Gilbert.
+ * Copyright (c) 1999-2018 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
@@ -20,22 +20,23 @@
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
-#include "sg_lib.h"
-#include "sg_cmds_basic.h"
-#include "sg_pt.h"
-#include "sg_unaligned.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include "sg_lib.h"
+#include "sg_cmds_basic.h"
+#include "sg_pt.h"
+#include "sg_unaligned.h"
+
/* Needs to be after config.h */
#ifdef SG_LIB_LINUX
#include <errno.h>
#endif
-static const char * const version_str = "1.77 20171030";
+static const char * const version_str = "1.78 20180104";
#define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */
diff --git a/lib/sg_cmds_basic2.c b/lib/sg_cmds_basic2.c
index 1e352312..f3cd379a 100644
--- a/lib/sg_cmds_basic2.c
+++ b/lib/sg_cmds_basic2.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999-2017 Douglas Gilbert.
+ * Copyright (c) 1999-2018 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
@@ -19,15 +19,16 @@
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
-#include "sg_lib.h"
-#include "sg_cmds_basic.h"
-#include "sg_pt.h"
-#include "sg_unaligned.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include "sg_lib.h"
+#include "sg_cmds_basic.h"
+#include "sg_pt.h"
+#include "sg_unaligned.h"
+
#define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */
diff --git a/lib/sg_cmds_extra.c b/lib/sg_cmds_extra.c
index fb1b02be..cbd8e626 100644
--- a/lib/sg_cmds_extra.c
+++ b/lib/sg_cmds_extra.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999-2017 Douglas Gilbert.
+ * Copyright (c) 1999-2018 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
@@ -13,6 +13,10 @@
#define __STDC_FORMAT_MACROS 1
#include <inttypes.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include "sg_lib.h"
#include "sg_lib_data.h"
#include "sg_cmds_basic.h"
@@ -20,10 +24,6 @@
#include "sg_pt.h"
#include "sg_unaligned.h"
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */
diff --git a/lib/sg_cmds_mmc.c b/lib/sg_cmds_mmc.c
index 026662f4..8df15be2 100644
--- a/lib/sg_cmds_mmc.c
+++ b/lib/sg_cmds_mmc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2017 Douglas Gilbert.
+ * Copyright (c) 2008-2018 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
@@ -13,16 +13,16 @@
#define __STDC_FORMAT_MACROS 1
#include <inttypes.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include "sg_lib.h"
#include "sg_cmds_basic.h"
#include "sg_cmds_mmc.h"
#include "sg_pt.h"
#include "sg_unaligned.h"
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */
diff --git a/lib/sg_io_linux.c b/lib/sg_io_linux.c
index 636b7fe4..f9f08e7e 100644
--- a/lib/sg_io_linux.c
+++ b/lib/sg_io_linux.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999-2016 Douglas Gilbert.
+ * Copyright (c) 1999-2018 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
diff --git a/lib/sg_lib.c b/lib/sg_lib.c
index 5055c414..f6bafb52 100644
--- a/lib/sg_lib.c
+++ b/lib/sg_lib.c
@@ -36,15 +36,15 @@
#define __STDC_FORMAT_MACROS 1
#include <inttypes.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include "sg_lib.h"
#include "sg_lib_data.h"
#include "sg_unaligned.h"
#include "sg_pr2serr.h"
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
/* sg_lib_version_str (and datestamp) defined in sg_lib_data.c file */
#define ASCQ_ATA_PT_INFO_AVAILABLE 0x1d /* corresponding ASC is 0 */
diff --git a/lib/sg_lib_data.c b/lib/sg_lib_data.c
index b6362a50..b3842632 100644
--- a/lib/sg_lib_data.c
+++ b/lib/sg_lib_data.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007-2017 Douglas Gilbert.
+ * Copyright (c) 2007-2018 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
@@ -7,17 +7,17 @@
#include <stdlib.h>
-#include "sg_lib.h"
-#include "sg_lib_data.h"
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#else
#define SG_SCSI_STRINGS 1
#endif
+#include "sg_lib.h"
+#include "sg_lib_data.h"
+
-const char * sg_lib_version_str = "2.35 20171227";/* spc5r17, sbc4r15 */
+const char * sg_lib_version_str = "2.36 20180104";/* spc5r17, sbc4r15 */
/* indexed by pdt; those that map to own index do not decay */
diff --git a/lib/sg_pt_common.c b/lib/sg_pt_common.c
index afff6479..ca053aa7 100644
--- a/lib/sg_pt_common.c
+++ b/lib/sg_pt_common.c
@@ -1,23 +1,141 @@
/*
- * Copyright (c) 2009-2017 Douglas Gilbert.
+ * Copyright (c) 2009-2018 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
*/
+#include <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <string.h>
+#include <ctype.h>
+#define __STDC_FORMAT_MACROS 1
+#include <inttypes.h>
-#include "sg_pt.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include "sg_lib.h"
+#include "sg_pt.h"
+#include "sg_pt_nvme.h"
+
+
+static const char * scsi_pt_version_str = "3.02 20180104";
+
+static const char * nvme_scsi_vendor_str = "NVMe ";
-static const char * scsi_pt_version_str = "3.01 20171107";
const char *
scsi_pt_version()
{
return scsi_pt_version_str;
}
+
+/* Given the NVMe Identify controller response and optionally the NVMe
+ * Identify namespace response (NULL otherwise), generate the SCSI VPD
+ * page 0x83 (device identification) descriptor(s) in dop. Return the
+ * number of bytes written which will not exceed max_do_len. Probably use
+ * Peripheral Device Type (pdt) of 0 (disk) for don't know. Transport
+ * protocol (tproto) should be -1 if not known, else SCSI value.
+ * N.B. Does not write total VPD page length into dop[2:3] . */
+int
+sg_make_vpd_devid_for_nvme(const uint8_t * nvme_id_ctl_p,
+ const uint8_t * nvme_id_ns_p, int pdt,
+ int tproto, uint8_t * dop, int max_do_len)
+{
+ bool have_nguid, have_eui64;
+ int k, n;
+ char b[4];
+
+ if ((NULL == nvme_id_ctl_p) || (NULL == dop) || (max_do_len < 56))
+ return 0;
+
+ memset(dop, 0, max_do_len);
+ dop[0] = 0x1f & pdt; /* (PQ=0)<<5 | (PDT=pdt); 0 or 0xd (SES) */
+ dop[1] = 0x83; /* Device Identification VPD page number */
+ /* Build a T10 Vendor ID based designator (desig_id=1) for controller */
+ if (tproto >= 0) {
+ dop[4] = ((0xf & tproto) << 4) | 0x2;
+ dop[5] = 0xa1; /* PIV=1, ASSOC=2 (target device), desig_id=1 */
+ } else {
+ dop[4] = 0x2; /* Prococol id=0, code_set=2 (ASCII) */
+ dop[5] = 0x21; /* PIV=0, ASSOC=2 (target device), desig_id=1 */
+ }
+ memcpy(dop + 8, nvme_scsi_vendor_str, 8); /* N.B. this is "NVMe " */
+ memcpy(dop + 16, nvme_id_ctl_p + 24, 40); /* MN */
+ for (k = 40; k > 0; --k) {
+ if (' ' == dop[15 + k])
+ dop[15 + k] = '_'; /* convert trailing spaces */
+ else
+ break;
+ }
+ if (40 == k)
+ --k;
+ n = 16 + 1 + k;
+ if (max_do_len < (n + 20))
+ return 0;
+ memcpy(dop + n, nvme_id_ctl_p + 4, 20); /* SN */
+ for (k = 20; k > 0; --k) { /* trim trailing spaces */
+ if (' ' == dop[n + k - 1])
+ dop[n + k - 1] = '\0';
+ else
+ break;
+ }
+ n += k;
+ if (0 != (n % 4))
+ n = ((n / 4) + 1) * 4; /* round up to next modulo 4 */
+ dop[7] = n - 8;
+ if (NULL == nvme_id_ns_p)
+ return n;
+
+ /* Look for NGUID (16 byte identifier) or EUI64 (8 byte) fields in
+ * NVME Identify for namespace. If found form a EUI and a SCSI string
+ * descriptor for non-zero NGUID or EUI64 (prefer NGUID if both). */
+ have_nguid = ! sg_all_zeros(nvme_id_ns_p + 104, 16);
+ have_eui64 = ! sg_all_zeros(nvme_id_ns_p + 120, 8);
+ if ((! have_nguid) && (! have_eui64))
+ return n;
+ if (have_nguid) {
+ if (max_do_len < (n + 20))
+ return n;
+ dop[n + 0] = 0x1; /* Prococol id=0, code_set=1 (binary) */
+ dop[n + 1] = 0x02; /* PIV=0, ASSOC=0 (lu), desig_id=2 (eui) */
+ dop[n + 3] = 16;
+ memcpy(dop + n + 4, nvme_id_ns_p + 104, 16);
+ n += 20;
+ if (max_do_len < (n + 40))
+ return n;
+ dop[n + 0] = 0x3; /* Prococol id=0, code_set=3 (utf8) */
+ dop[n + 1] = 0x08; /* PIV=0, ASSOC=0 (lu), desig_id=8 (scsi string) */
+ dop[n + 3] = 36;
+ memcpy(dop + n + 4, "eui.", 4);
+ for (k = 0; k < 16; ++k) {
+ snprintf(b, sizeof(b), "%02X", nvme_id_ns_p[104 + k]);
+ memcpy(dop + n + 8 + (2 * k), b, 2);
+ }
+ return n + 40;
+ } else { /* have_eui64 is true, 8 byte identifier */
+ if (max_do_len < (n + 12))
+ return n;
+ dop[n + 0] = 0x1; /* Prococol id=0, code_set=1 (binary) */
+ dop[n + 1] = 0x02; /* PIV=0, ASSOC=0 (lu), desig_id=2 (eui) */
+ dop[n + 3] = 8;
+ memcpy(dop + n + 4, nvme_id_ns_p + 120, 8);
+ n += 12;
+ if (max_do_len < (n + 24))
+ return n;
+ dop[n + 0] = 0x3; /* Prococol id=0, code_set=3 (utf8) */
+ dop[n + 1] = 0x08; /* PIV=0, ASSOC=0 (lu), desig_id=8 (scsi string) */
+ dop[n + 3] = 20;
+ memcpy(dop + n + 4, "eui.", 4);
+ for (k = 0; k < 8; ++k) {
+ snprintf(b, sizeof(b), "%02X", nvme_id_ns_p[120 + k]);
+ memcpy(dop + n + 8 + (2 * k), b, 2);
+ }
+ return n + 24;
+ }
+}
diff --git a/lib/sg_pt_freebsd.c b/lib/sg_pt_freebsd.c
index 0d2e38f9..9ded65ca 100644
--- a/lib/sg_pt_freebsd.c
+++ b/lib/sg_pt_freebsd.c
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2005-2017 Douglas Gilbert.
+ * Copyright (c) 2005-2018 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
*/
-/* sg_pt_freebsd version 1.20 20171227 */
+/* sg_pt_freebsd version 1.21 20180104 */
#include <stdio.h>
#include <stdlib.h>
@@ -31,16 +31,16 @@
#include <fcntl.h>
#include <stddef.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include "sg_pt.h"
#include "sg_lib.h"
#include "sg_unaligned.h"
#include "sg_pt_nvme.h"
#include "freebsd_nvme_ioctl.h"
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#define FREEBSD_MAXDEV 64
#define FREEBSD_FDOFFSET 16;
@@ -102,7 +102,7 @@ struct sg_pt_base {
struct sg_pt_freebsd_scsi impl;
};
-static const uint32_t broadcast_nsid = 0xffffffff;
+static const uint32_t broadcast_nsid = SG_NVME_BROADCAST_NSID;
#if defined(__GNUC__) || defined(__clang__)
static int pr2ws(const char * fmt, ...)
@@ -1115,9 +1115,12 @@ sntl_inq(struct sg_pt_freebsd_scsi * ptp, const uint8_t * cdbp, int vb)
{
bool evpd;
int res;
- uint16_t k, n, alloc_len, pg_cd;
+ uint16_t n, alloc_len, pg_cd;
+ uint32_t pg_sz = sg_get_page_size();
struct freebsd_dev_channel * fdc_p;
- uint8_t inq_dout[128];
+ uint8_t * nvme_id_ns = NULL;
+ uint8_t * free_nvme_id_ns = NULL;
+ uint8_t inq_dout[256];
if (vb > 3)
pr2ws("%s: starting\n", __func__);
@@ -1145,7 +1148,7 @@ sntl_inq(struct sg_pt_freebsd_scsi * ptp, const uint8_t * cdbp, int vb)
pg_cd = cdbp[2];
if (evpd) { /* VPD page responses */
switch (pg_cd) {
- case 0:
+ case 0: /* Supported VPD pages VPD page */
/* inq_dout[0] = (PQ=0)<<5 | (PDT=0); prefer pdt=0xd --> SES */
inq_dout[1] = pg_cd;
sg_put_unaligned_be16(3, inq_dout + 2);
@@ -1154,34 +1157,49 @@ sntl_inq(struct sg_pt_freebsd_scsi * ptp, const uint8_t * cdbp, int vb)
inq_dout[6] = 0x83;
n = 7;
break;
- case 0x80:
+ case 0x80: /* Serial number VPD page */
/* inq_dout[0] = (PQ=0)<<5 | (PDT=0); prefer pdt=0xd --> SES */
inq_dout[1] = pg_cd;
sg_put_unaligned_be16(20, inq_dout + 2);
memcpy(inq_dout + 4, fdc_p->nvme_id_ctlp + 4, 20); /* SN */
n = 24;
break;
- case 0x83:
- /* inq_dout[0] = (PQ=0)<<5 | (PDT=0); prefer pdt=0xd --> SES */
- inq_dout[1] = pg_cd;
- inq_dout[4] = 0x2; /* Prococol id=0, code_set=2 (ASCII) */
- inq_dout[5] = 0x1; /* PIV=0, ASSOC=0 (LU ??), desig_id=1 */
- /* Building T10 Vendor ID base designator, SNTL document 1.5
- * dated 20150624 confuses this with SCSI name string
- * descriptor, desig_id=8 */
- memcpy(inq_dout + 8, nvme_scsi_vendor_str, 8);
- memcpy(inq_dout + 16, fdc_p->nvme_id_ctlp + 24, 40); /* MN */
- for (k = 40; k > 0; --k) {
- if (' ' == inq_dout[16 + k - 1])
- inq_dout[16 + k - 1] = '_'; /* convert trailing spaces */
- else
- break;
+ case 0x83: /* Device identification VPD page */
+ if ((fdc_p->nsid > 0) && (fdc_p->nsid < SG_NVME_BROADCAST_NSID)) {
+ nvme_id_ns = sg_memalign(pg_sz, pg_sz, &free_nvme_id_ns,
+ vb > 3);
+ if (nvme_id_ns) {
+ struct nvme_pt_command npc;
+ uint8_t * npc_up = (uint8_t *)&npc;
+
+ memset(npc_up, 0, sizeof(npc));
+ npc_up[SG_NVME_PT_OPCODE] = 0x6; /* Identify */
+ sg_put_unaligned_le32(fdc_p->nsid,
+ npc_up + SG_NVME_PT_NSID);
+ /* CNS=0x0 Identify: namespace */
+ sg_put_unaligned_le32(0x0, npc_up + SG_NVME_PT_CDW10);
+ sg_put_unaligned_le64((sg_uintptr_t)nvme_id_ns,
+ npc_up + SG_NVME_PT_ADDR);
+ sg_put_unaligned_le32(pg_sz,
+ npc_up + SG_NVME_PT_DATA_LEN);
+ res = nvme_pt_low(fdc_p, nvme_id_ns, pg_sz, true, &npc,
+ vb > 3);
+ if (res) {
+ free(free_nvme_id_ns);
+ free_nvme_id_ns = NULL;
+ nvme_id_ns = NULL;
+ }
+ }
+ }
+ n = sg_make_vpd_devid_for_nvme(fdc_p->nvme_id_ctlp, nvme_id_ns, 0,
+ -1, inq_dout, sizeof(inq_dout));
+ if (n > 3)
+ sg_put_unaligned_be16(n - 4, inq_dout + 2);
+ if (free_nvme_id_ns) {
+ free(free_nvme_id_ns);
+ free_nvme_id_ns = NULL;
+ nvme_id_ns = NULL;
}
- /* SN */
- memcpy(inq_dout + 16 + k + 1, fdc_p->nvme_id_ctlp + 4, 20);
- n = 16 + k + 1 + 20;
- inq_dout[7] = 8 + k + 1 + 20;
- sg_put_unaligned_be16(n - 4, inq_dout + 2);
break;
default: /* Point to page_code field in cdb */
mk_sense_invalid_fld(ptp, true, 2, 7, vb);
diff --git a/lib/sg_pt_linux.c b/lib/sg_pt_linux.c
index f956f123..51526eca 100644
--- a/lib/sg_pt_linux.c
+++ b/lib/sg_pt_linux.c
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2005-2017 Douglas Gilbert.
+ * Copyright (c) 2005-2018 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
*/
-/* sg_pt_linux version 1.33 20171227 */
+/* sg_pt_linux version 1.34 20180104 */
#include <stdio.h>
diff --git a/lib/sg_pt_linux_nvme.c b/lib/sg_pt_linux_nvme.c
index a3d092d6..9c2d8124 100644
--- a/lib/sg_pt_linux_nvme.c
+++ b/lib/sg_pt_linux_nvme.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 Douglas Gilbert.
+ * Copyright (c) 2017-2018 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
@@ -282,7 +282,7 @@ mk_sense_invalid_fld(struct sg_pt_linux_scsi * ptp, bool in_cdb, int in_byte,
}
/* Returns 0 for success. Returns SG_LIB_NVME_STATUS if there is non-zero
- * NVMe status (from the completion queue) with the value in
+ * NVMe status (from the completion queue) with the value placed in
* ptp->nvme_status. If Unix error from ioctl add equivalent errno value to
* SG_LIB_OS_BASE_ERR. Should not return negative values. CDW0 from
* the completion queue is placed in ptp->nvme_result on success. */
@@ -389,8 +389,11 @@ sntl_inq(struct sg_pt_linux_scsi * ptp, const uint8_t * cdbp, int time_secs,
{
bool evpd;
int res;
- uint16_t k, n, alloc_len, pg_cd;
- uint8_t inq_dout[128];
+ uint16_t n, alloc_len, pg_cd;
+ uint32_t pg_sz = sg_get_page_size();
+ uint8_t * nvme_id_ns = NULL;
+ uint8_t * free_nvme_id_ns = NULL;
+ uint8_t inq_dout[256];
if (vb > 3)
pr2ws("%s: time_secs=%d\n", __func__, time_secs);
@@ -430,25 +433,38 @@ sntl_inq(struct sg_pt_linux_scsi * ptp, const uint8_t * cdbp, int time_secs,
n = 24;
break;
case 0x83:
- /* inq_dout[0] = (PQ=0)<<5 | (PDT=0); prefer pdt=0xd --> SES */
- inq_dout[1] = pg_cd;
- inq_dout[4] = 0x2; /* Prococol id=0, code_set=2 (ASCII) */
- inq_dout[5] = 0x1; /* PIV=0, ASSOC=0 (LU ??), desig_id=1 */
- /* Building T10 Vendor ID base designator, SNTL document 1.5
- * dated 20150624 confuses this with SCSI name string
- * descriptor, desig_id=8 */
- memcpy(inq_dout + 8, nvme_scsi_vendor_str, 8);
- memcpy(inq_dout + 16, ptp->nvme_id_ctlp + 24, 40); /* MN */
- for (k = 40; k > 0; --k) {
- if (' ' == inq_dout[16 + k - 1])
- inq_dout[16 + k - 1] = '_'; /* convert trailing spaces */
- else
- break;
+ if ((ptp->nvme_nsid > 0) &&
+ (ptp->nvme_nsid < SG_NVME_BROADCAST_NSID)) {
+ nvme_id_ns = sg_memalign(pg_sz, pg_sz, &free_nvme_id_ns,
+ vb > 3);
+ if (nvme_id_ns) {
+ struct sg_nvme_passthru_cmd cmd;
+
+ memset(&cmd, 0, sizeof(cmd));
+ cmd.opcode = 0x6; /* Identify */
+ cmd.nsid = ptp->nvme_nsid;
+ cmd.cdw10 = 0x0; /* CNS=0x0 Identify namespace */
+ cmd.addr = (uint64_t)(sg_uintptr_t)nvme_id_ns;
+ cmd.data_len = pg_sz;
+ res = do_nvme_admin_cmd(ptp, &cmd, nvme_id_ns, true,
+ time_secs, vb > 3);
+ if (res) {
+ free(free_nvme_id_ns);
+ free_nvme_id_ns = NULL;
+ nvme_id_ns = NULL;
+ }
+ }
+ }
+ n = sg_make_vpd_devid_for_nvme(ptp->nvme_id_ctlp, nvme_id_ns,
+ 0 /* pdt */, -1 /*tproto */,
+ inq_dout, sizeof(inq_dout));
+ if (n > 3)
+ sg_put_unaligned_be16(n - 4, inq_dout + 2);
+ if (free_nvme_id_ns) {
+ free(free_nvme_id_ns);
+ free_nvme_id_ns = NULL;
+ nvme_id_ns = NULL;
}
- memcpy(inq_dout + 16 + k + 1, ptp->nvme_id_ctlp + 4, 20); /* SN */
- n = 16 + k + 1 + 20;
- inq_dout[7] = 8 + k + 1 + 20;
- sg_put_unaligned_be16(n - 4, inq_dout + 2);
break;
default: /* Point to page_code field in cdb */
mk_sense_invalid_fld(ptp, true, 2, 7, vb);
diff --git a/lib/sg_pt_solaris.c b/lib/sg_pt_solaris.c
index 0fd1f23c..d31ce258 100644
--- a/lib/sg_pt_solaris.c
+++ b/lib/sg_pt_solaris.c
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2007-2017 Douglas Gilbert.
+ * Copyright (c) 2007-2018 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
*/
-/* sg_pt_solaris version 1.07 20171107 */
+/* sg_pt_solaris version 1.08 20180104 */
#include <stdio.h>
#include <stdlib.h>
@@ -24,13 +24,13 @@
#include <sys/scsi/impl/types.h>
#include <sys/scsi/impl/uscsi.h>
-#include "sg_pt.h"
-#include "sg_lib.h"
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include "sg_pt.h"
+#include "sg_lib.h"
+
#define DEF_TIMEOUT 60 /* 60 seconds */
diff --git a/lib/sg_pt_win32.c b/lib/sg_pt_win32.c
index af018244..32dfaa26 100644
--- a/lib/sg_pt_win32.c
+++ b/lib/sg_pt_win32.c
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2006-2017 Douglas Gilbert.
+ * Copyright (c) 2006-2018 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
*/
-/* sg_pt_win32 version 1.19 20171209 */
+/* sg_pt_win32 version 1.20 20180104 */
#include <stdio.h>
#include <stdlib.h>
@@ -16,13 +16,14 @@
#include <ctype.h>
#include <fcntl.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include "sg_pt.h"
#include "sg_lib.h"
#include "sg_pt_win32.h"
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
#ifndef O_EXCL
// #define O_EXCL 0x80 // cygwin ??