summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>2023-03-23 17:50:15 +0100
committerJes Sorensen <jes@trained-monkey.org>2023-05-08 16:23:45 -0400
commit0f8347d4f6588ee6ded55af3e307418cee286a6f (patch)
tree4aebed93e4b352701fdf87ba194097c8e7a7e4a2
parentb9ce7ab0218c550488587fdad5708628d6a5ffc2 (diff)
downloadmdadm-0f8347d4f6588ee6ded55af3e307418cee286a6f.tar.gz
mdadm: define DEV_NUM_PREF
Use define instead of inlines. Add _LEN define. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
-rw-r--r--config.c4
-rw-r--r--mdadm.h8
-rw-r--r--mdopen.c10
3 files changed, 15 insertions, 7 deletions
diff --git a/config.c b/config.c
index 59d5bfb..f44cc1d 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 67d73f9..f2e70ba 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 6c3bdb6..d3022a5 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -412,11 +412,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)