blob: 5fd6d668e238759ea2303ed6b251a30457a80a18 [file] [log] [blame]
Brad Bishop00ab2372019-10-14 11:06:18 -04001From 0f54b3120ca06ff3168cdbf901a27b68c4638398 Mon Sep 17 00:00:00 2001
2From: Changqing Li <changqing.li@windriver.com>
3Date: Thu, 26 Sep 2019 16:29:48 +0800
Andrew Geissler7f40b712020-05-15 14:09:53 -05004Subject: [PATCH] From 0000000000000000000000000000000000000000 Mon Sep
517
6 00:00:00 2001 From: Benjamin Marzinski <bmarzins@redhat.com> Date: Fri,
717
8 Oct 2014 11:20:34 -0500 Subject: [PATCH] RH: add wwids from kernel
9cmdline
Brad Bishop00ab2372019-10-14 11:06:18 -040010 mpath.wwids with -A
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080011
12This patch adds another option to multipath, "-A", which reads
13/proc/cmdline for mpath.wwid=<WWID> options, and adds any wwids it finds
14to /etc/multipath/wwids. While this isn't usually important during
15normal operation, since these wwids should already be added, it can be
16helpful during installation, to make sure that multipath can claim
17devices as its own, before LVM or something else makes use of them. The
18patch also execs "/sbin/multipath -A" before running multipathd in
19multipathd.service
20
21Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Brad Bishop19323692019-04-05 15:28:33 -040022
23Upstream-Status: Pending
24
Brad Bishop00ab2372019-10-14 11:06:18 -040025Update this patch to new version 0.8.2
Brad Bishop19323692019-04-05 15:28:33 -040026
27Signed-off-by: Changqing Li <changqing.li@windriver.com>
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080028---
Andrew Geissler7f40b712020-05-15 14:09:53 -050029 libmultipath/wwids.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
30 libmultipath/wwids.h | 1 +
31 2 files changed, 45 insertions(+)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080032
33diff --git a/libmultipath/wwids.c b/libmultipath/wwids.c
Andrew Geissler7f40b712020-05-15 14:09:53 -050034index 28a2150d..a0bfa851 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080035--- a/libmultipath/wwids.c
36+++ b/libmultipath/wwids.c
Andrew Geissler7f40b712020-05-15 14:09:53 -050037@@ -454,3 +454,47 @@ int op ## _wwid(const char *wwid) \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080038 declare_failed_wwid_op(is_failed, false)
39 declare_failed_wwid_op(mark_failed, true)
40 declare_failed_wwid_op(unmark_failed, true)
41+
42+int remember_cmdline_wwid(void)
43+{
Brad Bishop19323692019-04-05 15:28:33 -040044+ FILE *f = NULL;
45+ char buf[LINE_MAX], *next, *ptr;
46+ int ret = 0;
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080047+
Brad Bishop19323692019-04-05 15:28:33 -040048+ f = fopen("/proc/cmdline", "re");
49+ if (!f) {
50+ condlog(0, "can't open /proc/cmdline : %s", strerror(errno));
51+ return -1;
52+ }
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080053+
Brad Bishop19323692019-04-05 15:28:33 -040054+ if (!fgets(buf, sizeof(buf), f)) {
55+ if (ferror(f))
56+ condlog(0, "read of /proc/cmdline failed : %s",
57+ strerror(errno));
58+ else
59+ condlog(0, "couldn't read /proc/cmdline");
60+ fclose(f);
61+ return -1;
62+ }
63+ fclose(f);
64+ next = buf;
65+ while((ptr = strstr(next, "mpath.wwid="))) {
66+ ptr += 11;
67+ next = strpbrk(ptr, " \t\n");
68+ if (next) {
69+ *next = '\0';
70+ next++;
71+ }
72+ if (strlen(ptr)) {
73+ if (remember_wwid(ptr) != 0)
74+ ret = -1;
75+ }
76+ else {
77+ condlog(0, "empty mpath.wwid kernel command line option");
78+ ret = -1;
79+ }
80+ if (!next)
81+ break;
82+ }
83+ return ret;
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080084+}
85diff --git a/libmultipath/wwids.h b/libmultipath/wwids.h
Andrew Geissler7f40b712020-05-15 14:09:53 -050086index 0c6ee54d..e32a0b0e 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080087--- a/libmultipath/wwids.h
88+++ b/libmultipath/wwids.h
89@@ -17,6 +17,7 @@ int remember_wwid(char *wwid);
90 int check_wwids_file(char *wwid, int write_wwid);
91 int remove_wwid(char *wwid);
92 int replace_wwids(vector mp);
93+int remember_cmdline_wwid(void);
94
95 enum {
96 WWID_IS_NOT_FAILED = 0,
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080097--
Andrew Geissler7f40b712020-05-15 14:09:53 -0500982.17.1
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080099