device-mapper-multipath/0075-libmultipath-factor-out-code-to-get-vpd-page-data.patch
Benjamin Marzinski b05147c356 device-mapper-multipath-0.8.5-6
Change patch format to remove Git version
  * Patches 0001-0122 only have the patch format modified
Update to the head of the upstream staging branch plus redhat patches
  * Patches 0123-0134 & 1036-0142 are from the upstream staging branch
  * Patches 0143-1046 have been submitted upstream
  * Patch 0156 is a Red Hat only patch. Red Hat udev rules set ID_SERIAL
    from 60-persistent-storage.rules instead of 55-scsi-sg3_id.rules.
    Multipath's parse_vpd_pg83() function needs to match the ID_SERIAL
    value from udev.
Rename files
  * Previous patches 0123-0132 are now patches 1035 & 0147-0155
2021-03-26 13:33:56 -05:00

64 lines
1.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Benjamin Marzinski <bmarzins@redhat.com>
Date: Thu, 17 Dec 2020 16:51:02 -0600
Subject: [PATCH] libmultipath: factor out code to get vpd page data
A future patch will reuse the code to get the vpd page data, so factor
it out from get_vpd_sgio().
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
---
libmultipath/discovery.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index add7bb97..f901e9ff 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -1321,14 +1321,13 @@ get_vpd_sysfs (struct udev_device *parent, int pg, char * str, int maxlen)
return len;
}
-int
-get_vpd_sgio (int fd, int pg, int vend_id, char * str, int maxlen)
+static int
+fetch_vpd_page(int fd, int pg, unsigned char *buff, int maxlen)
{
- int len, buff_len;
- unsigned char buff[4096];
+ int buff_len;
- memset(buff, 0x0, 4096);
- if (sgio_get_vpd(buff, 4096, fd, pg) < 0) {
+ memset(buff, 0x0, maxlen);
+ if (sgio_get_vpd(buff, maxlen, fd, pg) < 0) {
int lvl = pg == 0x80 || pg == 0x83 ? 3 : 4;
condlog(lvl, "failed to issue vpd inquiry for pg%02x",
@@ -1342,10 +1341,22 @@ get_vpd_sgio (int fd, int pg, int vend_id, char * str, int maxlen)
return -ENODATA;
}
buff_len = get_unaligned_be16(&buff[2]) + 4;
- if (buff_len > 4096) {
+ if (buff_len > maxlen) {
condlog(3, "vpd pg%02x page truncated", pg);
- buff_len = 4096;
+ buff_len = maxlen;
}
+ return buff_len;
+}
+
+int
+get_vpd_sgio (int fd, int pg, int vend_id, char * str, int maxlen)
+{
+ int len, buff_len;
+ unsigned char buff[4096];
+
+ buff_len = fetch_vpd_page(fd, pg, buff, sizeof(buff));
+ if (buff_len < 0)
+ return buff_len;
if (pg == 0x80)
len = parse_vpd_pg80(buff, str, maxlen);
else if (pg == 0x83)