Blame SOURCES/0039-libmultipath-factor-out-code-to-get-vpd-page-data.patch

05be62
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
05be62
From: Benjamin Marzinski <bmarzins@redhat.com>
05be62
Date: Tue, 3 Nov 2020 14:27:58 -0600
05be62
Subject: [PATCH] libmultipath: factor out code to get vpd page data
05be62
05be62
A future patch will reuse the code to get the vpd page data, so factor
05be62
it out from get_vpd_sgio().
05be62
05be62
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
05be62
---
05be62
 libmultipath/discovery.c | 19 +++++++++++++++----
05be62
 1 file changed, 15 insertions(+), 4 deletions(-)
05be62
05be62
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
05be62
index aa5942c3..eb1e735d 100644
05be62
--- a/libmultipath/discovery.c
05be62
+++ b/libmultipath/discovery.c
05be62
@@ -1239,11 +1239,10 @@ get_vpd_sysfs (struct udev_device *parent, int pg, char * str, int maxlen)
05be62
 	return len;
05be62
 }
05be62
 
05be62
-int
05be62
-get_vpd_sgio (int fd, int pg, int vend_id, char * str, int maxlen)
05be62
+static int
05be62
+fetch_vpd_page(int fd, int pg, unsigned char *buff)
05be62
 {
05be62
-	int len, buff_len;
05be62
-	unsigned char buff[4096];
05be62
+	int buff_len;
05be62
 
05be62
 	memset(buff, 0x0, 4096);
05be62
 	if (sgio_get_vpd(buff, 4096, fd, pg) < 0) {
05be62
@@ -1264,6 +1263,18 @@ get_vpd_sgio (int fd, int pg, int vend_id, char * str, int maxlen)
05be62
 		condlog(3, "vpd pg%02x page truncated", pg);
05be62
 		buff_len = 4096;
05be62
 	}
05be62
+	return buff_len;
05be62
+}
05be62
+
05be62
+int
05be62
+get_vpd_sgio (int fd, int pg, int vend_id, char * str, int maxlen)
05be62
+{
05be62
+	int len, buff_len;
05be62
+	unsigned char buff[4096];
05be62
+
05be62
+	buff_len = fetch_vpd_page(fd, pg, buff);
05be62
+	if (buff_len < 0)
05be62
+		return buff_len;
05be62
 	if (pg == 0x80)
05be62
 		len = parse_vpd_pg80(buff, str, maxlen);
05be62
 	else if (pg == 0x83)
05be62
-- 
05be62
2.17.2
05be62