From: jcejka@suse.com
To: linux-raid@vger.kernel.org
Cc: Josef Cejka <jcejka@suse.com>
Subject: [PATCH v2] mdadm: allow to assemble /dev/md_xxx named arrays.
Date: Thu, 10 Aug 2017 11:41:41 +0200 [thread overview]
Message-ID: <20170810094141.27575-1-jcejka@suse.com> (raw)
In-Reply-To: <20170803163236.28958-1-jcejka@suse.com>
From: Josef Cejka <jcejka@suse.com>
Allow to assemble arrays using /dev/md_xxx name format
both from cmdline like mdadm -A /dev/md_xxx
or using ASSEMBLE directive in mdadm.conf
Signed-off-by: Josef Cejka <jcejka@suse.com>
Reviewed-by: Coly Li <colyli@suse.de>
---
config.c | 5 +++--
mdopen.c | 26 ++++++++++++++++----------
2 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/config.c b/config.c
index 48e0278..113ef01 100644
--- a/config.c
+++ b/config.c
@@ -389,6 +389,7 @@ void arrayline(char *line)
* /dev/md/{anything}
* /dev/mdNN
* /dev/md_dNN
+ * /dev/md_XXX
* <ignore>
* or anything that doesn't start '/' or '<'
*/
@@ -397,8 +398,8 @@ void arrayline(char *line)
(w[0] != '/' && w[0] != '<') ||
(strncmp(w, "/dev/md", 7) == 0 &&
is_number(w + 7)) ||
- (strncmp(w, "/dev/md_d", 9) == 0 &&
- is_number(w + 9))) {
+ (strncmp(w, "/dev/md_", 8) == 0 &&
+ strlen(w) > 8)) {
/* This is acceptable */;
if (mis.devname)
pr_err("only give one device per ARRAY line: %s and %s\n",
diff --git a/mdopen.c b/mdopen.c
index c4f1c12..0f3a244 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -174,19 +174,25 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
num = strtoul(e, NULL, 10);
strcpy(cname, dev+5);
cname[e-(dev+5)] = 0;
- /* name *must* be mdXX or md_dXX in this context */
+ /* name is not mdXX or md_dXX */
if (num < 0 ||
(strcmp(cname, "md") != 0 && strcmp(cname, "md_d") != 0)) {
- pr_err("%s is an invalid name for an md device. Try /dev/md/%s\n",
- dev, dev+5);
- return -1;
+ if (strncmp(cname, "md_", 3) != 0) {
+ pr_err("%s is an invalid name for an md device. Try /dev/md/%s\n",
+ dev, dev+5);
+ return -1;
+ }
+ /* /dev/md_<string> format */
+ strcpy(cname, dev+8);
+ num = -1;
+ } else {
+ if (strcmp(cname, "md") == 0)
+ use_mdp = 0;
+ else
+ use_mdp = 1;
+ /* recreate name: /dev/md/0 or /dev/md/d0 */
+ sprintf(cname, "%s%d", use_mdp?"d":"", num);
}
- if (strcmp(cname, "md") == 0)
- use_mdp = 0;
- else
- use_mdp = 1;
- /* recreate name: /dev/md/0 or /dev/md/d0 */
- sprintf(cname, "%s%d", use_mdp?"d":"", num);
} else
strcpy(cname, dev);
--
2.12.3
next prev parent reply other threads:[~2017-08-10 9:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-03 16:32 [PATCH] mdadm: allow to assemble /dev/md_xxx named arrays jcejka
2017-08-10 9:41 ` jcejka [this message]
2017-08-10 12:24 ` Coly Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170810094141.27575-1-jcejka@suse.com \
--to=jcejka@suse.com \
--cc=linux-raid@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox