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

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