100 lines
3.2 KiB
Diff
100 lines
3.2 KiB
Diff
|
From 0f54b3120ca06ff3168cdbf901a27b68c4638398 Mon Sep 17 00:00:00 2001
|
||
|
From: Changqing Li <changqing.li@windriver.com>
|
||
|
Date: Thu, 26 Sep 2019 16:29:48 +0800
|
||
|
Subject: [PATCH] From 0000000000000000000000000000000000000000 Mon Sep
|
||
|
17
|
||
|
00:00:00 2001 From: Benjamin Marzinski <bmarzins@redhat.com> Date: Fri,
|
||
|
17
|
||
|
Oct 2014 11:20:34 -0500 Subject: [PATCH] RH: add wwids from kernel
|
||
|
cmdline
|
||
|
mpath.wwids with -A
|
||
|
|
||
|
This patch adds another option to multipath, "-A", which reads
|
||
|
/proc/cmdline for mpath.wwid=<WWID> options, and adds any wwids it finds
|
||
|
to /etc/multipath/wwids. While this isn't usually important during
|
||
|
normal operation, since these wwids should already be added, it can be
|
||
|
helpful during installation, to make sure that multipath can claim
|
||
|
devices as its own, before LVM or something else makes use of them. The
|
||
|
patch also execs "/sbin/multipath -A" before running multipathd in
|
||
|
multipathd.service
|
||
|
|
||
|
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
||
|
|
||
|
Upstream-Status: Pending
|
||
|
|
||
|
Update this patch to new version 0.8.2
|
||
|
|
||
|
Signed-off-by: Changqing Li <changqing.li@windriver.com>
|
||
|
---
|
||
|
libmultipath/wwids.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
|
||
|
libmultipath/wwids.h | 1 +
|
||
|
2 files changed, 45 insertions(+)
|
||
|
|
||
|
diff --git a/libmultipath/wwids.c b/libmultipath/wwids.c
|
||
|
index 28a2150d..a0bfa851 100644
|
||
|
--- a/libmultipath/wwids.c
|
||
|
+++ b/libmultipath/wwids.c
|
||
|
@@ -454,3 +454,47 @@ int op ## _wwid(const char *wwid) \
|
||
|
declare_failed_wwid_op(is_failed, false)
|
||
|
declare_failed_wwid_op(mark_failed, true)
|
||
|
declare_failed_wwid_op(unmark_failed, true)
|
||
|
+
|
||
|
+int remember_cmdline_wwid(void)
|
||
|
+{
|
||
|
+ FILE *f = NULL;
|
||
|
+ char buf[LINE_MAX], *next, *ptr;
|
||
|
+ int ret = 0;
|
||
|
+
|
||
|
+ f = fopen("/proc/cmdline", "re");
|
||
|
+ if (!f) {
|
||
|
+ condlog(0, "can't open /proc/cmdline : %s", strerror(errno));
|
||
|
+ return -1;
|
||
|
+ }
|
||
|
+
|
||
|
+ if (!fgets(buf, sizeof(buf), f)) {
|
||
|
+ if (ferror(f))
|
||
|
+ condlog(0, "read of /proc/cmdline failed : %s",
|
||
|
+ strerror(errno));
|
||
|
+ else
|
||
|
+ condlog(0, "couldn't read /proc/cmdline");
|
||
|
+ fclose(f);
|
||
|
+ return -1;
|
||
|
+ }
|
||
|
+ fclose(f);
|
||
|
+ next = buf;
|
||
|
+ while((ptr = strstr(next, "mpath.wwid="))) {
|
||
|
+ ptr += 11;
|
||
|
+ next = strpbrk(ptr, " \t\n");
|
||
|
+ if (next) {
|
||
|
+ *next = '\0';
|
||
|
+ next++;
|
||
|
+ }
|
||
|
+ if (strlen(ptr)) {
|
||
|
+ if (remember_wwid(ptr) != 0)
|
||
|
+ ret = -1;
|
||
|
+ }
|
||
|
+ else {
|
||
|
+ condlog(0, "empty mpath.wwid kernel command line option");
|
||
|
+ ret = -1;
|
||
|
+ }
|
||
|
+ if (!next)
|
||
|
+ break;
|
||
|
+ }
|
||
|
+ return ret;
|
||
|
+}
|
||
|
diff --git a/libmultipath/wwids.h b/libmultipath/wwids.h
|
||
|
index 0c6ee54d..e32a0b0e 100644
|
||
|
--- a/libmultipath/wwids.h
|
||
|
+++ b/libmultipath/wwids.h
|
||
|
@@ -17,6 +17,7 @@ int remember_wwid(char *wwid);
|
||
|
int check_wwids_file(char *wwid, int write_wwid);
|
||
|
int remove_wwid(char *wwid);
|
||
|
int replace_wwids(vector mp);
|
||
|
+int remember_cmdline_wwid(void);
|
||
|
|
||
|
enum {
|
||
|
WWID_IS_NOT_FAILED = 0,
|
||
|
--
|
||
|
2.17.1
|
||
|
|