From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
To: jes@trained-monkey.org
Cc: linux-raid@vger.kernel.org, colyli@suse.de, xni@redhat.com
Subject: [PATCH 2/4] mdadm: define DEV_NUM_PREF
Date: Thu, 23 Mar 2023 17:50:15 +0100 [thread overview]
Message-ID: <20230323165017.27121-3-mariusz.tkaczyk@linux.intel.com> (raw)
In-Reply-To: <20230323165017.27121-1-mariusz.tkaczyk@linux.intel.com>
Use define instead of inlines. Add _LEN define.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
config.c | 4 ++--
mdadm.h | 8 ++++++++
mdopen.c | 10 +++++-----
3 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/config.c b/config.c
index 59d5bfb6..f44cc1d3 100644
--- a/config.c
+++ b/config.c
@@ -407,8 +407,8 @@ void arrayline(char *line)
if (strcasecmp(w, "<ignore>") == 0 ||
strncmp(w, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0 ||
(w[0] != '/' && w[0] != '<') ||
- (strncmp(w, "/dev/md", 7) == 0 &&
- is_number(w + 7)) ||
+ (strncmp(w, DEV_NUM_PREF, DEV_NUM_PREF_LEN) == 0 &&
+ is_number(w + DEV_NUM_PREF_LEN)) ||
(strncmp(w, "/dev/md_d", 9) == 0 &&
is_number(w + 9))) {
/* This is acceptable */;
diff --git a/mdadm.h b/mdadm.h
index cb644fd8..63ec88a0 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -100,6 +100,14 @@ struct dlm_lksb {
#define DEFAULT_BITMAP_DELAY 5
#define DEFAULT_MAX_WRITE_BEHIND 256
+/* DEV_NUM_PREF is a subpath to numbered MD devices, e.g. /dev/md1 or directory name.
+ * DEV_NUM_PREF_LEN is a length with Null byte excluded.
+ */
+#ifndef DEV_NUM_PREF
+#define DEV_NUM_PREF "/dev/md"
+#define DEV_NUM_PREF_LEN (sizeof(DEV_NUM_PREF) - 1)
+#endif /* DEV_NUM_PREF */
+
/* DEV_MD_DIR points to named MD devices directory.
* DEV_MD_DIR_LEN is a length with Null byte excluded.
*/
diff --git a/mdopen.c b/mdopen.c
index ed86df60..b270fdd5 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -411,11 +411,11 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
make_parts(devname, parts);
if (strcmp(chosen, devname) != 0) {
- if (mkdir("/dev/md",0700) == 0) {
- if (chown("/dev/md", ci->uid, ci->gid))
- perror("chown /dev/md");
- if (chmod("/dev/md", ci->mode| ((ci->mode>>2) & 0111)))
- perror("chmod /dev/md");
+ if (mkdir(DEV_NUM_PREF, 0700) == 0) {
+ if (chown(DEV_NUM_PREF, ci->uid, ci->gid))
+ perror("chown " DEV_NUM_PREF);
+ if (chmod(DEV_NUM_PREF, ci->mode | ((ci->mode >> 2) & 0111)))
+ perror("chmod " DEV_NUM_PREF);
}
if (dev && strcmp(chosen, dev) == 0)
--
2.26.2
next prev parent reply other threads:[~2023-03-23 16:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 16:50 [PATCH 0/4] Few config related refactors Mariusz Tkaczyk
2023-03-23 16:50 ` [PATCH 1/4] mdadm: define DEV_MD_DIR Mariusz Tkaczyk
2023-03-23 16:50 ` Mariusz Tkaczyk [this message]
2023-03-23 16:50 ` [PATCH 3/4] mdadm: define is_devname_ignore() Mariusz Tkaczyk
2023-03-23 16:50 ` [PATCH 4/4] mdadm: numbered names verification Mariusz Tkaczyk
2023-03-24 2:13 ` [PATCH 0/4] Few config related refactors Xiao Ni
2023-04-20 10:46 ` Mariusz Tkaczyk
2023-05-08 20:26 ` Jes Sorensen
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=20230323165017.27121-3-mariusz.tkaczyk@linux.intel.com \
--to=mariusz.tkaczyk@linux.intel.com \
--cc=colyli@suse.de \
--cc=jes@trained-monkey.org \
--cc=linux-raid@vger.kernel.org \
--cc=xni@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).