1From 969fbb35e40100f599d4a9781911251f21792698 Mon Sep 17 00:00:00 2001 2From: Changqing Li <changqing.li@windriver.com> 3Date: Thu, 27 Jan 2022 17:53:01 +0800 4Subject: [PATCH] Fix parsing of "-r" in monitor/manager mode 5 6This revert commit 546047688e1 [mdadm: fix coredump of mdadm --monitor 7-r], and fix the coredump issue of 'mdadm --monitor -r'. 8 9commit 546047688e1 make -r not work in manager mode, and testcase 1000multipath failed. 11 12Upstream-Status: Submitted [send to maintainer jsorensen@fb.com] 13 14Signed-off-by: Changqing Li <changqing.li@windriver.com> 15 16--- 17 ReadMe.c | 8 +++++--- 18 mdadm.c | 2 ++ 19 mdadm.h | 1 + 20 3 files changed, 8 insertions(+), 3 deletions(-) 21 22diff --git a/ReadMe.c b/ReadMe.c 23index 8139976..070eea5 100644 24--- a/ReadMe.c 25+++ b/ReadMe.c 26@@ -81,11 +81,13 @@ char Version[] = "mdadm - v" VERSION " - " VERS_DATE EXTRAVERSION "\n"; 27 * found, it is started. 28 */ 29 30-char short_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:r:n:x:u:c:d:z:U:N:safRSow1tye:k"; 31+char short_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:k:"; 32 char short_bitmap_options[]= 33- "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:r:n:x:u:c:d:z:U:N:sarfRSow1tye:k:"; 34+ "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:k:"; 35 char short_bitmap_auto_options[]= 36- "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:r:n:x:u:c:d:z:U:N:sa:rfRSow1tye:k:"; 37+ "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sa:rfRSow1tye:k:"; 38+char short_increment_options[]= 39+ "-ABCDEFGIQhVXYWZ:vqbc:i:l:r:p:m:n:x:u:c:d:z:U:N:safRSow1tye:k:"; 40 41 struct option long_options[] = { 42 {"manage", 0, 0, ManageOpt}, 43diff --git a/mdadm.c b/mdadm.c 44index 26299b2..2a3b2ee 100644 45--- a/mdadm.c 46+++ b/mdadm.c 47@@ -227,6 +227,7 @@ int main(int argc, char *argv[]) 48 shortopt = short_bitmap_auto_options; 49 break; 50 case 'F': newmode = MONITOR; 51+ shortopt = short_increment_options; 52 break; 53 case 'G': newmode = GROW; 54 shortopt = short_bitmap_options; 55@@ -268,6 +269,7 @@ int main(int argc, char *argv[]) 56 57 case NoSharing: 58 newmode = MONITOR; 59+ shortopt = short_increment_options; 60 break; 61 } 62 if (mode && newmode == mode) { 63diff --git a/mdadm.h b/mdadm.h 64index ecfc137..42148dd 100644 65--- a/mdadm.h 66+++ b/mdadm.h 67@@ -421,6 +421,7 @@ enum mode { 68 extern char short_options[]; 69 extern char short_bitmap_options[]; 70 extern char short_bitmap_auto_options[]; 71+extern char short_increment_options[]; 72 extern struct option long_options[]; 73 extern char Version[], Usage[], Help[], OptionHelp[], 74 *mode_help[], 75