From 969fbb35e40100f599d4a9781911251f21792698 Mon Sep 17 00:00:00 2001 From: Changqing Li Date: Thu, 27 Jan 2022 17:53:01 +0800 Subject: [PATCH] Fix parsing of "-r" in monitor/manager mode This revert commit 546047688e1 [mdadm: fix coredump of mdadm --monitor -r], and fix the coredump issue of 'mdadm --monitor -r'. commit 546047688e1 make -r not work in manager mode, and testcase 00multipath failed. Upstream-Status: Submitted [send to maintainer jsorensen@fb.com] Signed-off-by: Changqing Li --- ReadMe.c | 8 +++++--- mdadm.c | 2 ++ mdadm.h | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ReadMe.c b/ReadMe.c index 8139976..070eea5 100644 --- a/ReadMe.c +++ b/ReadMe.c @@ -81,11 +81,13 @@ char Version[] = "mdadm - v" VERSION " - " VERS_DATE EXTRAVERSION "\n"; * found, it is started. */ -char short_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:r:n:x:u:c:d:z:U:N:safRSow1tye:k"; +char short_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:k:"; char short_bitmap_options[]= - "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:r:n:x:u:c:d:z:U:N:sarfRSow1tye:k:"; + "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:k:"; char short_bitmap_auto_options[]= - "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:r:n:x:u:c:d:z:U:N:sa:rfRSow1tye:k:"; + "-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sa:rfRSow1tye:k:"; +char short_increment_options[]= + "-ABCDEFGIQhVXYWZ:vqbc:i:l:r:p:m:n:x:u:c:d:z:U:N:safRSow1tye:k:"; struct option long_options[] = { {"manage", 0, 0, ManageOpt}, diff --git a/mdadm.c b/mdadm.c index 26299b2..2a3b2ee 100644 --- a/mdadm.c +++ b/mdadm.c @@ -227,6 +227,7 @@ int main(int argc, char *argv[]) shortopt = short_bitmap_auto_options; break; case 'F': newmode = MONITOR; + shortopt = short_increment_options; break; case 'G': newmode = GROW; shortopt = short_bitmap_options; @@ -268,6 +269,7 @@ int main(int argc, char *argv[]) case NoSharing: newmode = MONITOR; + shortopt = short_increment_options; break; } if (mode && newmode == mode) { diff --git a/mdadm.h b/mdadm.h index ecfc137..42148dd 100644 --- a/mdadm.h +++ b/mdadm.h @@ -421,6 +421,7 @@ enum mode { extern char short_options[]; extern char short_bitmap_options[]; extern char short_bitmap_auto_options[]; +extern char short_increment_options[]; extern struct option long_options[]; extern char Version[], Usage[], Help[], OptionHelp[], *mode_help[],