28d3ae407e
This is an automated DistroBaker update from upstream sources. If you do not know what this is about or would like to opt out, contact the OSCI team. Source: https://src.fedoraproject.org/rpms/device-mapper-multipath.git#26a2cd7a3e189bf91263d17bc8a8c449cc043fb0
67 lines
1.9 KiB
Diff
67 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)
|
|
--
|
|
2.17.2
|
|
|