summaryrefslogtreecommitdiffstats
path: root/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'config.c')
-rw-r--r--config.c108
1 files changed, 33 insertions, 75 deletions
diff --git a/config.c b/config.c
index 6ea905f..3359504 100644
--- a/config.c
+++ b/config.c
@@ -24,6 +24,8 @@
#include "mdadm.h"
#include "dlink.h"
+#include "xmalloc.h"
+
#include <dirent.h>
#include <glob.h>
#include <fnmatch.h>
@@ -169,7 +171,6 @@ inline void ident_init(struct mddev_ident *ident)
assert(ident);
ident->assembled = false;
- ident->autof = 0;
ident->bitmap_fd = -1;
ident->bitmap_file = NULL;
ident->container = NULL;
@@ -360,39 +361,41 @@ struct mddev_dev *load_partitions(void)
struct mddev_dev *load_containers(void)
{
struct mdstat_ent *mdstat = mdstat_read(0, 0);
+ struct mddev_dev *dev_list = NULL;
+ struct map_ent *map_list = NULL;
struct mdstat_ent *ent;
- struct mddev_dev *d;
- struct mddev_dev *rv = NULL;
- struct map_ent *map = NULL, *me;
- if (!mdstat)
- return NULL;
+ for (ent = mdstat; ent; ent = ent->next) {
+ struct mddev_dev *d;
+ struct map_ent *map;
- for (ent = mdstat; ent; ent = ent->next)
- if (ent->metadata_version &&
- strncmp(ent->metadata_version, "external:", 9) == 0 &&
- !is_subarray(&ent->metadata_version[9])) {
- d = xcalloc(1, sizeof(*d));
- me = map_by_devnm(&map, ent->devnm);
- if (me)
- d->devname = xstrdup(me->path);
- else if (asprintf(&d->devname, "/dev/%s", ent->devnm) < 0) {
- free(d);
- continue;
- }
- d->next = rv;
- rv = d;
- map_free(map);
- map = NULL;
+ if (!is_mdstat_ent_external(ent))
+ continue;
+
+ if (is_mdstat_ent_subarray(ent))
+ continue;
+
+ d = xcalloc(1, sizeof(*d));
+
+ map = map_by_devnm(&map_list, ent->devnm);
+ if (map) {
+ d->devname = xstrdup(map->path);
+ } else if (asprintf(&d->devname, "/dev/%s", ent->devnm) < 0) {
+ free(d);
+ continue;
}
+
+ d->next = dev_list;
+ dev_list = d;
+ }
+
free_mdstat(mdstat);
- map_free(map);
+ map_free(map_list);
- return rv;
+ return dev_list;
}
struct createinfo createinfo = {
- .autof = 2, /* by default, create devices with standard names */
.names = 0, /* By default, stick with numbered md devices. */
.bblist = 1, /* Use a bad block list by default */
#ifdef DEBIAN
@@ -403,52 +406,6 @@ struct createinfo createinfo = {
#endif
};
-int parse_auto(char *str, char *msg, int config)
-{
- int autof;
- if (str == NULL || *str == 0)
- autof = 2;
- else if (strcasecmp(str, "no") == 0)
- autof = 1;
- else if (strcasecmp(str, "yes") == 0)
- autof = 2;
- else if (strcasecmp(str, "md") == 0)
- autof = config ? 5:3;
- else {
- /* There might be digits, and maybe a hypen, at the end */
- char *e = str + strlen(str);
- int num = 4;
- int len;
- while (e > str && isdigit(e[-1]))
- e--;
- if (*e) {
- num = atoi(e);
- if (num <= 0)
- num = 1;
- }
- if (e > str && e[-1] == '-')
- e--;
- len = e - str;
- if ((len == 2 && strncasecmp(str, "md", 2) == 0)) {
- autof = config ? 5 : 3;
- } else if ((len == 3 && strncasecmp(str, "yes", 3) == 0)) {
- autof = 2;
- } else if ((len == 3 && strncasecmp(str, "mdp", 3) == 0)) {
- autof = config ? 6 : 4;
- } else if ((len == 1 && strncasecmp(str, "p", 1) == 0) ||
- (len >= 4 && strncasecmp(str, "part", 4) == 0)) {
- autof = 6;
- } else {
- pr_err("%s arg of \"%s\" unrecognised: use no,yes,md,mdp,part\n"
- " optionally followed by a number.\n",
- msg, str);
- exit(2);
- }
- autof |= num << 3;
- }
- return autof;
-}
-
static void createline(char *line)
{
char *w;
@@ -456,7 +413,8 @@ static void createline(char *line)
for (w = dl_next(line); w != line; w = dl_next(w)) {
if (strncasecmp(w, "auto=", 5) == 0)
- createinfo.autof = parse_auto(w + 5, "auto=", 1);
+ /* auto is no supported now, ignore it silently */
+ continue;
else if (strncasecmp(w, "owner=", 6) == 0) {
if (w[6] == 0) {
pr_err("missing owner name\n");
@@ -625,9 +583,9 @@ void arrayline(char *line)
if (!mis.st)
pr_err("metadata format %s unknown, ignored.\n",
w + 9);
- } else if (strncasecmp(w, "auto=", 5) == 0 ) {
- /* whether to create device special files as needed */
- mis.autof = parse_auto(w + 5, "auto type", 0);
+ } else if (strncasecmp(w, "auto=", 5) == 0) {
+ /* Ignore for backward compatibility */
+ continue;
} else if (strncasecmp(w, "member=", 7) == 0) {
/* subarray within a container */
mis.member = xstrdup(w + 7);