Linux Device Mapper development
 help / color / mirror / Atom feed
From: Martin Wilck <mwilck@suse.com>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>,
	Benjamin Marzinski <bmarzins@redhat.com>
Cc: dm-devel@redhat.com, Martin Wilck <mwilck@suse.com>
Subject: [PATCH v2 1/9] libmultipath: add sysfs_get_inquiry()
Date: Fri, 15 Mar 2019 18:19:22 +0100	[thread overview]
Message-ID: <20190315171930.28335-2-mwilck@suse.com> (raw)
In-Reply-To: <20190315171930.28335-1-mwilck@suse.com>

Provide a utility function to retrieve inquiry data from
sysfs, like we do for VPDs.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 libmultipath/discovery.c | 23 ++++++++++++++++++-----
 libmultipath/discovery.h |  6 ++++--
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 10bd8cd6..65d651d4 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -218,12 +218,11 @@ declare_sysfs_get_str(vendor);
 declare_sysfs_get_str(model);
 declare_sysfs_get_str(rev);
 
-ssize_t
-sysfs_get_vpd (struct udev_device * udev, int pg,
-	       unsigned char * buff, size_t len)
+static ssize_t
+sysfs_get_binary (struct udev_device * udev, const char *attrname,
+		  unsigned char *buff, size_t len)
 {
 	ssize_t attr_len;
-	char attrname[9];
 	const char * devname;
 
 	if (!udev) {
@@ -232,7 +231,6 @@ sysfs_get_vpd (struct udev_device * udev, int pg,
 	}
 
 	devname = udev_device_get_sysname(udev);
-	sprintf(attrname, "vpd_pg%02x", pg);
 	attr_len = sysfs_bin_attr_get_value(udev, attrname, buff, len);
 	if (attr_len < 0) {
 		condlog(3, "%s: attribute %s not found in sysfs",
@@ -242,6 +240,21 @@ sysfs_get_vpd (struct udev_device * udev, int pg,
 	return attr_len;
 }
 
+ssize_t sysfs_get_vpd(struct udev_device * udev, unsigned char pg,
+		      unsigned char *buff, size_t len)
+{
+	char attrname[9];
+
+	snprintf(attrname, sizeof(attrname), "vpd_pg%02x", pg);
+	return sysfs_get_binary(udev, attrname, buff, len);
+}
+
+ssize_t sysfs_get_inquiry(struct udev_device * udev,
+			  unsigned char *buff, size_t len)
+{
+	return sysfs_get_binary(udev, "inquiry", buff, len);
+}
+
 int
 sysfs_get_timeout(struct path *pp, unsigned int *timeout)
 {
diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h
index 9aacf75b..7cacbb6c 100644
--- a/libmultipath/discovery.h
+++ b/libmultipath/discovery.h
@@ -48,8 +48,10 @@ int sysfs_get_host_pci_name(const struct path *pp, char *pci_name);
 int sysfs_get_iscsi_ip_address(const struct path *pp, char *ip_address);
 int sysfs_get_host_adapter_name(const struct path *pp,
 				char *adapter_name);
-ssize_t sysfs_get_vpd (struct udev_device * udev, int pg, unsigned char * buff,
-		       size_t len);
+ssize_t sysfs_get_vpd (struct udev_device *udev, unsigned char pg,
+		       unsigned char *buff, size_t len);
+ssize_t sysfs_get_inquiry(struct udev_device *udev,
+			  unsigned char *buff, size_t len);
 int sysfs_get_asymmetric_access_state(struct path *pp,
 				      char *buff, int buflen);
 int get_uid(struct path * pp, int path_state, struct udev_device *udev);
-- 
2.21.0

  reply	other threads:[~2019-03-15 17:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-15 17:19 [PATCH v2 0/9] multipath-tools: avoid I/O during uevent processing Martin Wilck
2019-03-15 17:19 ` Martin Wilck [this message]
2019-03-15 17:19 ` [PATCH v2 2/9] libmultipath: alua: make API more consistent Martin Wilck
2019-03-15 17:19 ` [PATCH v2 3/9] libmultipath: alua: try to retrieve inquiry data from sysfs Martin Wilck
2019-03-18  7:08   ` Hannes Reinecke
2019-03-18  9:47     ` Martin Wilck
2019-03-15 17:19 ` [PATCH v2 4/9] libmultipath: constify sysfs_get_timeout() Martin Wilck
2019-03-15 17:19 ` [PATCH v2 5/9] libmultipath: detect_alua(): use system timeout Martin Wilck
2019-03-15 17:19 ` [PATCH v2 6/9] libmultipath: lazy tpgs probing Martin Wilck
2019-03-15 17:19 ` [PATCH v2 7/9] libmultipath: don't link alua_rtpg.o twice Martin Wilck
2019-03-15 17:19 ` [PATCH v2 8/9] libmultipath: check_rdac(): pre-check in hwtable Martin Wilck
2019-03-18  7:10   ` Hannes Reinecke
2019-03-18  9:52     ` Martin Wilck
2019-03-18 10:06       ` Martin Wilck
2019-03-15 17:19 ` [PATCH v2 9/9] libmultipath: hwtable: add Lenovo DE series Martin Wilck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190315171930.28335-2-mwilck@suse.com \
    --to=mwilck@suse.com \
    --cc=bmarzins@redhat.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox