Page MenuHomeFreeBSD

D33973.diff
No OneTemporary

D33973.diff

diff --git a/sys/cam/cam.h b/sys/cam/cam.h
--- a/sys/cam/cam.h
+++ b/sys/cam/cam.h
@@ -378,6 +378,8 @@
int entry_size, cam_quirkmatch_t *comp_func);
void cam_strvis(u_int8_t *dst, const u_int8_t *src, int srclen, int dstlen);
+void cam_strvis_flag(u_int8_t *dst, const u_int8_t *src, int srclen,
+ int dstlen, uint32_t flags);
void cam_strvis_sbuf(struct sbuf *sb, const u_int8_t *src, int srclen,
uint32_t flags);
diff --git a/sys/cam/cam.c b/sys/cam/cam.c
--- a/sys/cam/cam.c
+++ b/sys/cam/cam.c
@@ -123,38 +123,19 @@
void
cam_strvis(u_int8_t *dst, const u_int8_t *src, int srclen, int dstlen)
{
+ cam_strvis_flag(dst, src, srclen, dstlen,
+ CAM_STRVIS_FLAG_NONASCII_ESC);
+}
- /* Trim leading/trailing spaces, nulls. */
- while (srclen > 0 && src[0] == ' ')
- src++, srclen--;
- while (srclen > 0
- && (src[srclen-1] == ' ' || src[srclen-1] == '\0'))
- srclen--;
-
- while (srclen > 0 && dstlen > 1) {
- u_int8_t *cur_pos = dst;
+void
+cam_strvis_flag(u_int8_t *dst, const u_int8_t *src, int srclen, int dstlen,
+ uint32_t flags)
+{
+ struct sbuf sb;
- if (*src < 0x20 || *src >= 0x80) {
- /* SCSI-II Specifies that these should never occur. */
- /* non-printable character */
- if (dstlen > 4) {
- *cur_pos++ = '\\';
- *cur_pos++ = ((*src & 0300) >> 6) + '0';
- *cur_pos++ = ((*src & 0070) >> 3) + '0';
- *cur_pos++ = ((*src & 0007) >> 0) + '0';
- } else {
- *cur_pos++ = '?';
- }
- } else {
- /* normal character */
- *cur_pos++ = *src;
- }
- src++;
- srclen--;
- dstlen -= cur_pos - dst;
- dst = cur_pos;
- }
- *dst = '\0';
+ sbuf_new(&sb, dst, dstlen, SBUF_FIXEDLEN);
+ cam_strvis_sbuf(&sb, src, srclen, flags);
+ sbuf_finish(&sb);
}
void
diff --git a/sys/cam/nvme/nvme_all.c b/sys/cam/nvme/nvme_all.c
--- a/sys/cam/nvme/nvme_all.c
+++ b/sys/cam/nvme/nvme_all.c
@@ -91,11 +91,14 @@
{
sbuf_printf(sb, "<");
- cam_strvis_sbuf(sb, cdata->mn, sizeof(cdata->mn), 0);
+ cam_strvis_sbuf(sb, cdata->mn, sizeof(cdata->mn),
+ CAM_STRVIS_FLAG_NONASCII_SPC);
sbuf_printf(sb, " ");
- cam_strvis_sbuf(sb, cdata->fr, sizeof(cdata->fr), 0);
+ cam_strvis_sbuf(sb, cdata->fr, sizeof(cdata->fr),
+ CAM_STRVIS_FLAG_NONASCII_SPC);
sbuf_printf(sb, " ");
- cam_strvis_sbuf(sb, cdata->sn, sizeof(cdata->sn), 0);
+ cam_strvis_sbuf(sb, cdata->sn, sizeof(cdata->sn),
+ CAM_STRVIS_FLAG_NONASCII_SPC);
sbuf_printf(sb, ">\n");
}
diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c
--- a/sys/cam/nvme/nvme_da.c
+++ b/sys/cam/nvme/nvme_da.c
@@ -930,10 +930,12 @@
* d_ident and d_descr are both far bigger than the length of either
* the serial or model number strings.
*/
- cam_strvis(disk->d_descr, cd->mn,
- NVME_MODEL_NUMBER_LENGTH, sizeof(disk->d_descr));
- cam_strvis(disk->d_ident, cd->sn,
- NVME_SERIAL_NUMBER_LENGTH, sizeof(disk->d_ident));
+ cam_strvis_flag(disk->d_descr, cd->mn, NVME_MODEL_NUMBER_LENGTH,
+ sizeof(disk->d_descr), CAM_STRVIS_FLAG_NONASCII_SPC);
+
+ cam_strvis_flag(disk->d_ident, cd->sn, NVME_SERIAL_NUMBER_LENGTH,
+ sizeof(disk->d_ident), CAM_STRVIS_FLAG_NONASCII_SPC);
+
disk->d_hba_vendor = cpi.hba_vendor;
disk->d_hba_device = cpi.hba_device;
disk->d_hba_subvendor = cpi.hba_subvendor;
diff --git a/sys/cam/nvme/nvme_xpt.c b/sys/cam/nvme/nvme_xpt.c
--- a/sys/cam/nvme/nvme_xpt.c
+++ b/sys/cam/nvme/nvme_xpt.c
@@ -376,8 +376,11 @@
path->device->serial_num = (u_int8_t *)
malloc(NVME_SERIAL_NUMBER_LENGTH + 1, M_CAMXPT, M_NOWAIT);
if (path->device->serial_num != NULL) {
- cam_strvis(path->device->serial_num, nvme_cdata->sn,
- NVME_SERIAL_NUMBER_LENGTH, NVME_SERIAL_NUMBER_LENGTH + 1);
+ cam_strvis_flag(path->device->serial_num,
+ nvme_cdata->sn, sizeof(nvme_cdata->sn),
+ NVME_SERIAL_NUMBER_LENGTH + 1,
+ CAM_STRVIS_FLAG_NONASCII_SPC);
+
path->device->serial_num_len =
strlen(path->device->serial_num);
}

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 8, 4:41 PM (21 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14538734
Default Alt Text
D33973.diff (3 KB)

Event Timeline