summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2011-04-05 08:40:49 +1000
committerNeilBrown <neilb@suse.de>2011-04-05 08:40:49 +1000
commit32367cb5588be10b25c11a69795d18b9af9d2f8c (patch)
tree4c3915c20dee26b54d2f6a6a999a0f13dc63735c
parent679eb882fc243bfeb6a2586ded92bf5331096a3d (diff)
split name/number maps into separate file.
This reduced some interdependencies between files. Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r--Makefile21
-rw-r--r--ReadMe.c106
-rw-r--r--maps.c153
-rw-r--r--mdassemble.c22
-rw-r--r--util.c21
5 files changed, 160 insertions, 163 deletions
diff --git a/Makefile b/Makefile
index 6985fc1b..eca11c2b 100644
--- a/Makefile
+++ b/Makefile
@@ -98,7 +98,8 @@ MAN4DIR = $(MANDIR)/man4
MAN5DIR = $(MANDIR)/man5
MAN8DIR = $(MANDIR)/man8
-OBJS = mdadm.o config.o policy.o mdstat.o ReadMe.o util.o Manage.o Assemble.o Build.o \
+OBJS = mdadm.o config.o policy.o mdstat.o ReadMe.o util.o maps.o \
+ Manage.o Assemble.o Build.o \
Create.o Detail.o Examine.o Grow.o Monitor.o dlink.o Kill.o Query.o \
Incremental.o \
mdopen.o super0.o super1.o super-ddf.o super-intel.o bitmap.o \
@@ -108,32 +109,24 @@ OBJS = mdadm.o config.o policy.o mdstat.o ReadMe.o util.o Manage.o Assemble.o
OBJSX = restripe.o
-SRCS = mdadm.c config.c policy.c mdstat.c ReadMe.c util.c Manage.c Assemble.c Build.c \
- Create.c Detail.c Examine.c Grow.c Monitor.c dlink.c Kill.c Query.c \
- Incremental.c \
- mdopen.c super0.c super1.c super-ddf.c super-intel.c bitmap.c \
- super-mbr.c super-gpt.c \
- restripe.c sysfs.c sha1.c mapfile.c crc32.c sg_io.c msg.c \
- platform-intel.c probe_roms.c
+SRCS = $(patsubst %.o,%.c,$(OBJS))
INCL = mdadm.h part.h bitmap.h
-MON_OBJS = mdmon.o monitor.o managemon.o util.o mdstat.o sysfs.o config.o policy.o \
+MON_OBJS = mdmon.o monitor.o managemon.o util.o maps.o mdstat.o sysfs.o \
+ config.o policy.o \
Kill.o sg_io.o dlink.o ReadMe.o super0.o super1.o super-intel.o \
super-mbr.o super-gpt.o \
super-ddf.o sha1.o crc32.o msg.o bitmap.o \
platform-intel.o probe_roms.o
-MON_SRCS = mdmon.c monitor.c managemon.c util.c mdstat.c sysfs.c config.c policy.c \
- Kill.c sg_io.c dlink.c ReadMe.c super0.c super1.c super-intel.c \
- super-mbr.c super-gpt.c \
- super-ddf.c sha1.c crc32.c msg.c bitmap.c \
- platform-intel.c probe_roms.c
+MON_SRCS = $(patsubst %.o,%.c,$(MON_OBJS))
STATICSRC = pwgr.c
STATICOBJS = pwgr.o
ASSEMBLE_SRCS := mdassemble.c Assemble.c Manage.c config.c policy.c dlink.c util.c \
+ maps.c \
super0.c super1.c super-ddf.c super-intel.c sha1.c crc32.c sg_io.c mdstat.c \
platform-intel.c probe_roms.c sysfs.c super-mbr.c super-gpt.c
ASSEMBLE_AUTO_SRCS := mdopen.c
diff --git a/ReadMe.c b/ReadMe.c
index dee3d0c2..00b24d4f 100644
--- a/ReadMe.c
+++ b/ReadMe.c
@@ -600,109 +600,3 @@ char Help_config[] =
"\n"
;
-
-/* name/number mappings */
-
-mapping_t r5layout[] = {
- { "left-asymmetric", ALGORITHM_LEFT_ASYMMETRIC},
- { "right-asymmetric", ALGORITHM_RIGHT_ASYMMETRIC},
- { "left-symmetric", ALGORITHM_LEFT_SYMMETRIC},
- { "right-symmetric", ALGORITHM_RIGHT_SYMMETRIC},
-
- { "default", ALGORITHM_LEFT_SYMMETRIC},
- { "la", ALGORITHM_LEFT_ASYMMETRIC},
- { "ra", ALGORITHM_RIGHT_ASYMMETRIC},
- { "ls", ALGORITHM_LEFT_SYMMETRIC},
- { "rs", ALGORITHM_RIGHT_SYMMETRIC},
-
- { "parity-first", ALGORITHM_PARITY_0},
- { "parity-last", ALGORITHM_PARITY_N},
- { "ddf-zero-restart", ALGORITHM_RIGHT_ASYMMETRIC},
- { "ddf-N-restart", ALGORITHM_LEFT_ASYMMETRIC},
- { "ddf-N-continue", ALGORITHM_LEFT_SYMMETRIC},
-
- { NULL, 0}
-};
-mapping_t r6layout[] = {
- { "left-asymmetric", ALGORITHM_LEFT_ASYMMETRIC},
- { "right-asymmetric", ALGORITHM_RIGHT_ASYMMETRIC},
- { "left-symmetric", ALGORITHM_LEFT_SYMMETRIC},
- { "right-symmetric", ALGORITHM_RIGHT_SYMMETRIC},
-
- { "default", ALGORITHM_LEFT_SYMMETRIC},
- { "la", ALGORITHM_LEFT_ASYMMETRIC},
- { "ra", ALGORITHM_RIGHT_ASYMMETRIC},
- { "ls", ALGORITHM_LEFT_SYMMETRIC},
- { "rs", ALGORITHM_RIGHT_SYMMETRIC},
-
- { "parity-first", ALGORITHM_PARITY_0},
- { "parity-last", ALGORITHM_PARITY_N},
- { "ddf-zero-restart", ALGORITHM_ROTATING_ZERO_RESTART},
- { "ddf-N-restart", ALGORITHM_ROTATING_N_RESTART},
- { "ddf-N-continue", ALGORITHM_ROTATING_N_CONTINUE},
-
- { "left-asymmetric-6", ALGORITHM_LEFT_ASYMMETRIC_6},
- { "right-asymmetric-6", ALGORITHM_RIGHT_ASYMMETRIC_6},
- { "left-symmetric-6", ALGORITHM_LEFT_SYMMETRIC_6},
- { "right-symmetric-6", ALGORITHM_RIGHT_SYMMETRIC_6},
- { "parity-first-6", ALGORITHM_PARITY_0_6},
-
- { NULL, 0}
-};
-
-mapping_t pers[] = {
- { "linear", LEVEL_LINEAR},
- { "raid0", 0},
- { "0", 0},
- { "stripe", 0},
- { "raid1", 1},
- { "1", 1},
- { "mirror", 1},
- { "raid4", 4},
- { "4", 4},
- { "raid5", 5},
- { "5", 5},
- { "multipath", LEVEL_MULTIPATH},
- { "mp", LEVEL_MULTIPATH},
- { "raid6", 6},
- { "6", 6},
- { "raid10", 10},
- { "10", 10},
- { "faulty", LEVEL_FAULTY},
- { "container", LEVEL_CONTAINER},
- { NULL, 0}
-};
-
-
-mapping_t modes[] = {
- { "assemble", ASSEMBLE},
- { "build", BUILD},
- { "create", CREATE},
- { "manage", MANAGE},
- { "misc", MISC},
- { "monitor", MONITOR},
- { "grow", GROW},
- { "incremental", INCREMENTAL},
- { "auto-detect", AUTODETECT},
-};
-
-mapping_t faultylayout[] = {
- { "write-transient", WriteTransient },
- { "wt", WriteTransient },
- { "read-transient", ReadTransient },
- { "rt", ReadTransient },
- { "write-persistent", WritePersistent },
- { "wp", WritePersistent },
- { "read-persistent", ReadPersistent },
- { "rp", ReadPersistent },
- { "write-all", WriteAll },
- { "wa", WriteAll },
- { "read-fixable", ReadFixable },
- { "rf", ReadFixable },
-
- { "clear", ClearErrors},
- { "flush", ClearFaults},
- { "none", ClearErrors},
- { "default", ClearErrors},
- { NULL, 0}
-};
diff --git a/maps.c b/maps.c
new file mode 100644
index 00000000..f2ba9a73
--- /dev/null
+++ b/maps.c
@@ -0,0 +1,153 @@
+/*
+ * mdadm - manage Linux "md" devices aka RAID arrays.
+ *
+ * Copyright (C) 2011 Neil Brown <neilb@suse.de>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Neil Brown
+ * Email: <neilb@suse.de>
+ */
+
+#include "mdadm.h"
+
+
+/* name/number mappings */
+
+mapping_t r5layout[] = {
+ { "left-asymmetric", ALGORITHM_LEFT_ASYMMETRIC},
+ { "right-asymmetric", ALGORITHM_RIGHT_ASYMMETRIC},
+ { "left-symmetric", ALGORITHM_LEFT_SYMMETRIC},
+ { "right-symmetric", ALGORITHM_RIGHT_SYMMETRIC},
+
+ { "default", ALGORITHM_LEFT_SYMMETRIC},
+ { "la", ALGORITHM_LEFT_ASYMMETRIC},
+ { "ra", ALGORITHM_RIGHT_ASYMMETRIC},
+ { "ls", ALGORITHM_LEFT_SYMMETRIC},
+ { "rs", ALGORITHM_RIGHT_SYMMETRIC},
+
+ { "parity-first", ALGORITHM_PARITY_0},
+ { "parity-last", ALGORITHM_PARITY_N},
+ { "ddf-zero-restart", ALGORITHM_RIGHT_ASYMMETRIC},
+ { "ddf-N-restart", ALGORITHM_LEFT_ASYMMETRIC},
+ { "ddf-N-continue", ALGORITHM_LEFT_SYMMETRIC},
+
+ { NULL, 0}
+};
+mapping_t r6layout[] = {
+ { "left-asymmetric", ALGORITHM_LEFT_ASYMMETRIC},
+ { "right-asymmetric", ALGORITHM_RIGHT_ASYMMETRIC},
+ { "left-symmetric", ALGORITHM_LEFT_SYMMETRIC},
+ { "right-symmetric", ALGORITHM_RIGHT_SYMMETRIC},
+
+ { "default", ALGORITHM_LEFT_SYMMETRIC},
+ { "la", ALGORITHM_LEFT_ASYMMETRIC},
+ { "ra", ALGORITHM_RIGHT_ASYMMETRIC},
+ { "ls", ALGORITHM_LEFT_SYMMETRIC},
+ { "rs", ALGORITHM_RIGHT_SYMMETRIC},
+
+ { "parity-first", ALGORITHM_PARITY_0},
+ { "parity-last", ALGORITHM_PARITY_N},
+ { "ddf-zero-restart", ALGORITHM_ROTATING_ZERO_RESTART},
+ { "ddf-N-restart", ALGORITHM_ROTATING_N_RESTART},
+ { "ddf-N-continue", ALGORITHM_ROTATING_N_CONTINUE},
+
+ { "left-asymmetric-6", ALGORITHM_LEFT_ASYMMETRIC_6},
+ { "right-asymmetric-6", ALGORITHM_RIGHT_ASYMMETRIC_6},
+ { "left-symmetric-6", ALGORITHM_LEFT_SYMMETRIC_6},
+ { "right-symmetric-6", ALGORITHM_RIGHT_SYMMETRIC_6},
+ { "parity-first-6", ALGORITHM_PARITY_0_6},
+
+ { NULL, 0}
+};
+
+mapping_t pers[] = {
+ { "linear", LEVEL_LINEAR},
+ { "raid0", 0},
+ { "0", 0},
+ { "stripe", 0},
+ { "raid1", 1},
+ { "1", 1},
+ { "mirror", 1},
+ { "raid4", 4},
+ { "4", 4},
+ { "raid5", 5},
+ { "5", 5},
+ { "multipath", LEVEL_MULTIPATH},
+ { "mp", LEVEL_MULTIPATH},
+ { "raid6", 6},
+ { "6", 6},
+ { "raid10", 10},
+ { "10", 10},
+ { "faulty", LEVEL_FAULTY},
+ { "container", LEVEL_CONTAINER},
+ { NULL, 0}
+};
+
+
+mapping_t modes[] = {
+ { "assemble", ASSEMBLE},
+ { "build", BUILD},
+ { "create", CREATE},
+ { "manage", MANAGE},
+ { "misc", MISC},
+ { "monitor", MONITOR},
+ { "grow", GROW},
+ { "incremental", INCREMENTAL},
+ { "auto-detect", AUTODETECT},
+};
+
+mapping_t faultylayout[] = {
+ { "write-transient", WriteTransient },
+ { "wt", WriteTransient },
+ { "read-transient", ReadTransient },
+ { "rt", ReadTransient },
+ { "write-persistent", WritePersistent },
+ { "wp", WritePersistent },
+ { "read-persistent", ReadPersistent },
+ { "rp", ReadPersistent },
+ { "write-all", WriteAll },
+ { "wa", WriteAll },
+ { "read-fixable", ReadFixable },
+ { "rf", ReadFixable },
+
+ { "clear", ClearErrors},
+ { "flush", ClearFaults},
+ { "none", ClearErrors},
+ { "default", ClearErrors},
+ { NULL, 0}
+};
+
+char *map_num(mapping_t *map, int num)
+{
+ while (map->name) {
+ if (map->num == num)
+ return map->name;
+ map++;
+ }
+ return NULL;
+}
+
+int map_name(mapping_t *map, char *name)
+{
+ while (map->name) {
+ if (strcmp(map->name, name)==0)
+ return map->num;
+ map++;
+ }
+ return UnSet;
+}
+
diff --git a/mdassemble.c b/mdassemble.c
index a8b78ceb..66e480a8 100644
--- a/mdassemble.c
+++ b/mdassemble.c
@@ -26,28 +26,6 @@
#include "mdadm.h"
#include "md_p.h"
-/* from readme.c */
-mapping_t pers[] = {
- { "linear", LEVEL_LINEAR},
- { "raid0", 0},
- { "0", 0},
- { "stripe", 0},
- { "raid1", 1},
- { "1", 1},
- { "mirror", 1},
- { "raid4", 4},
- { "4", 4},
- { "raid5", 5},
- { "5", 5},
- { "multipath", LEVEL_MULTIPATH},
- { "mp", LEVEL_MULTIPATH},
- { "raid6", 6},
- { "6", 6},
- { "raid10", 10},
- { "10", 10},
- { NULL, 0}
-};
-
#ifndef MDASSEMBLE_AUTO
/* from mdopen.c */
int open_mddev(char *dev, int report_errors/*unused*/)
diff --git a/util.c b/util.c
index e0671eb6..45e68739 100644
--- a/util.c
+++ b/util.c
@@ -566,27 +566,6 @@ int ask(char *mesg)
}
#endif /* MDASSEMBLE */
-char *map_num(mapping_t *map, int num)
-{
- while (map->name) {
- if (map->num == num)
- return map->name;
- map++;
- }
- return NULL;
-}
-
-int map_name(mapping_t *map, char *name)
-{
- while (map->name) {
- if (strcmp(map->name, name)==0)
- return map->num;
- map++;
- }
- return UnSet;
-}
-
-
int is_standard(char *dev, int *nump)
{
/* tests if dev is a "standard" md dev name.