|
|
429878 |
From 357a807e81bbd1430b045eb2601a64b17d588400 Mon Sep 17 00:00:00 2001
|
|
|
429878 |
From: David Teigland <teigland@redhat.com>
|
|
|
429878 |
Date: Thu, 2 Dec 2021 13:30:36 -0600
|
|
|
ab86b0 |
Subject: [PATCH 20/54] device_id: handle wwid with spaces or control
|
|
|
429878 |
characters
|
|
|
429878 |
|
|
|
429878 |
non-standard wwid can be reported from sysfs with spaces/etc.
|
|
|
429878 |
replace with "_"
|
|
|
429878 |
---
|
|
|
429878 |
lib/device/device_id.c | 10 ++++++----
|
|
|
429878 |
1 file changed, 6 insertions(+), 4 deletions(-)
|
|
|
429878 |
|
|
|
429878 |
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
|
|
|
429878 |
index 4c2b5a3dd..0621bc858 100644
|
|
|
429878 |
--- a/lib/device/device_id.c
|
|
|
429878 |
+++ b/lib/device/device_id.c
|
|
|
429878 |
@@ -304,6 +304,7 @@ const char *device_id_system_read(struct cmd_context *cmd, struct device *dev, u
|
|
|
429878 |
{
|
|
|
429878 |
char sysbuf[PATH_MAX] = { 0 };
|
|
|
429878 |
const char *idname = NULL;
|
|
|
429878 |
+ int i;
|
|
|
429878 |
|
|
|
429878 |
if (idtype == DEV_ID_TYPE_SYS_WWID) {
|
|
|
429878 |
read_sys_block(cmd, dev, "device/wwid", sysbuf, sizeof(sysbuf));
|
|
|
429878 |
@@ -311,10 +312,6 @@ const char *device_id_system_read(struct cmd_context *cmd, struct device *dev, u
|
|
|
429878 |
if (!sysbuf[0])
|
|
|
429878 |
read_sys_block(cmd, dev, "wwid", sysbuf, sizeof(sysbuf));
|
|
|
429878 |
|
|
|
429878 |
- /* scsi_debug wwid begins "t10.Linux scsi_debug ..." */
|
|
|
429878 |
- if (strstr(sysbuf, "scsi_debug"))
|
|
|
429878 |
- sysbuf[0] = '\0';
|
|
|
429878 |
-
|
|
|
429878 |
/* qemu wwid begins "t10.ATA QEMU HARDDISK ..." */
|
|
|
429878 |
if (strstr(sysbuf, "QEMU HARDDISK"))
|
|
|
429878 |
sysbuf[0] = '\0';
|
|
|
429878 |
@@ -355,6 +352,11 @@ const char *device_id_system_read(struct cmd_context *cmd, struct device *dev, u
|
|
|
429878 |
return idname;
|
|
|
429878 |
}
|
|
|
429878 |
|
|
|
429878 |
+ for (i = 0; i < strlen(sysbuf); i++) {
|
|
|
429878 |
+ if (isblank(sysbuf[i]) || isspace(sysbuf[i]) || iscntrl(sysbuf[i]))
|
|
|
429878 |
+ sysbuf[i] = '_';
|
|
|
429878 |
+ }
|
|
|
429878 |
+
|
|
|
429878 |
if (!sysbuf[0])
|
|
|
429878 |
goto_bad;
|
|
|
429878 |
|
|
|
429878 |
--
|
|
|
ab86b0 |
2.34.3
|
|
|
429878 |
|