blob: 17c36e86c5a3e2ac417e40854eba1c46bd12efb9 [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001From 262de33671ede81e424344ea9125d9e546cf8612 Mon Sep 17 00:00:00 2001
Brad Bishop00ab2372019-10-14 11:06:18 -04002From: 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
Andrew Geissler517393d2023-01-13 08:55:19 -06005
Andrew Geissler7f40b712020-05-15 14:09:53 -0500617
7 00:00:00 2001 From: Benjamin Marzinski <bmarzins@redhat.com> Date: Fri,
817
9 Oct 2014 11:20:34 -0500 Subject: [PATCH] RH: add wwids from kernel
10cmdline
Brad Bishop00ab2372019-10-14 11:06:18 -040011 mpath.wwids with -A
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080012
13This patch adds another option to multipath, "-A", which reads
14/proc/cmdline for mpath.wwid=<WWID> options, and adds any wwids it finds
15to /etc/multipath/wwids. While this isn't usually important during
16normal operation, since these wwids should already be added, it can be
17helpful during installation, to make sure that multipath can claim
18devices as its own, before LVM or something else makes use of them. The
19patch also execs "/sbin/multipath -A" before running multipathd in
20multipathd.service
21
22Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Brad Bishop19323692019-04-05 15:28:33 -040023
24Upstream-Status: Pending
25
Brad Bishop00ab2372019-10-14 11:06:18 -040026Update this patch to new version 0.8.2
Brad Bishop19323692019-04-05 15:28:33 -040027
28Signed-off-by: Changqing Li <changqing.li@windriver.com>
Andrew Geissler517393d2023-01-13 08:55:19 -060029[OP: Rebase to 0.9.3]
30Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080031---
Andrew Geissler7f40b712020-05-15 14:09:53 -050032 libmultipath/wwids.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
33 libmultipath/wwids.h | 1 +
34 2 files changed, 45 insertions(+)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080035
36diff --git a/libmultipath/wwids.c b/libmultipath/wwids.c
Andrew Geissler517393d2023-01-13 08:55:19 -060037index 89bb60ca..bab9aa85 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080038--- a/libmultipath/wwids.c
39+++ b/libmultipath/wwids.c
Andrew Geissler517393d2023-01-13 08:55:19 -060040@@ -451,3 +451,47 @@ int unmark_failed_wwid(const char *wwid)
41 print_failed_wwid_result("unmark_failed", wwid, r);
42 return r;
43 }
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080044+
45+int remember_cmdline_wwid(void)
46+{
Brad Bishop19323692019-04-05 15:28:33 -040047+ FILE *f = NULL;
48+ char buf[LINE_MAX], *next, *ptr;
49+ int ret = 0;
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080050+
Brad Bishop19323692019-04-05 15:28:33 -040051+ f = fopen("/proc/cmdline", "re");
52+ if (!f) {
53+ condlog(0, "can't open /proc/cmdline : %s", strerror(errno));
54+ return -1;
55+ }
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080056+
Brad Bishop19323692019-04-05 15:28:33 -040057+ if (!fgets(buf, sizeof(buf), f)) {
58+ if (ferror(f))
59+ condlog(0, "read of /proc/cmdline failed : %s",
60+ strerror(errno));
61+ else
62+ condlog(0, "couldn't read /proc/cmdline");
63+ fclose(f);
64+ return -1;
65+ }
66+ fclose(f);
67+ next = buf;
68+ while((ptr = strstr(next, "mpath.wwid="))) {
69+ ptr += 11;
70+ next = strpbrk(ptr, " \t\n");
71+ if (next) {
72+ *next = '\0';
73+ next++;
74+ }
75+ if (strlen(ptr)) {
76+ if (remember_wwid(ptr) != 0)
77+ ret = -1;
78+ }
79+ else {
80+ condlog(0, "empty mpath.wwid kernel command line option");
81+ ret = -1;
82+ }
83+ if (!next)
84+ break;
85+ }
86+ return ret;
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080087+}
88diff --git a/libmultipath/wwids.h b/libmultipath/wwids.h
Andrew Geissler7f40b712020-05-15 14:09:53 -050089index 0c6ee54d..e32a0b0e 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080090--- a/libmultipath/wwids.h
91+++ b/libmultipath/wwids.h
92@@ -17,6 +17,7 @@ int remember_wwid(char *wwid);
93 int check_wwids_file(char *wwid, int write_wwid);
94 int remove_wwid(char *wwid);
95 int replace_wwids(vector mp);
96+int remember_cmdline_wwid(void);
97
98 enum {
99 WWID_IS_NOT_FAILED = 0,
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800100--
Andrew Geissler517393d2023-01-13 08:55:19 -06001012.38.1
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800102