]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - config.c
DDF: use LBA_OFFSET macro instead of lba_offset field
[thirdparty/mdadm.git] / config.c
index 0eb2c8d1c7f7275cb8ff0b275733be8bb568ffbe..5c8b03a3838d7a1548aef5a2b326663ef097b399 100644 (file)
--- a/config.c
+++ b/config.c
@@ -108,46 +108,6 @@ int match_keyword(char *word)
        return -1;
 }
 
-/*
- * conf_line reads one logical line from the conffile.
- * It skips comments and continues until it finds a line that starts
- * with a non blank/comment.  This character is pushed back for the next call
- * A doubly linked list of words is returned.
- * the first word will be a keyword.  Other words will have had quotes removed.
- */
-
-char *conf_line(FILE *file)
-{
-       char *w;
-       char *list;
-
-       w = conf_word(file, 1);
-       if (w == NULL) return NULL;
-
-       list = dl_strdup(w);
-       free(w);
-       dl_init(list);
-
-       while ((w = conf_word(file,0))){
-               char *w2 = dl_strdup(w);
-               free(w);
-               dl_add(list, w2);
-       }
-/*    printf("got a line\n");*/
-       return list;
-}
-
-void free_line(char *line)
-{
-       char *w;
-       for (w=dl_next(line); w != line; w=dl_next(line)) {
-               dl_del(w);
-               dl_free(w);
-       }
-       dl_free(line);
-}
-
-
 struct conf_dev {
        struct conf_dev *next;
        char *name;
@@ -179,9 +139,9 @@ struct mddev_dev *load_partitions(void)
                if (!name)
                        continue;
                d = xmalloc(sizeof(*d));
+               memset(d, 0, sizeof(*d));
                d->devname = xstrdup(name);
                d->next = rv;
-               d->used = 0;
                rv = d;
        }
        fclose(f);
@@ -194,6 +154,7 @@ struct mddev_dev *load_containers(void)
        struct mdstat_ent *ent;
        struct mddev_dev *d;
        struct mddev_dev *rv = NULL;
+       struct map_ent *map = NULL, *me;
 
        if (!mdstat)
                return NULL;
@@ -203,15 +164,19 @@ struct mddev_dev *load_containers(void)
                    strncmp(ent->metadata_version, "external:", 9) == 0 &&
                    !is_subarray(&ent->metadata_version[9])) {
                        d = xmalloc(sizeof(*d));
-                       if (asprintf(&d->devname, "/dev/%s", ent->dev) < 0) {
+                       memset(d, 0, sizeof(*d));
+                       me = map_by_devnm(&map, ent->dev);
+                       if (me)
+                               d->devname = xstrdup(me->path);
+                       else if (asprintf(&d->devname, "/dev/%s", ent->dev) < 0) {
                                free(d);
                                continue;
                        }
                        d->next = rv;
-                       d->used = 0;
                        rv = d;
                }
        free_mdstat(mdstat);
+       map_free(map);
 
        return rv;
 }
@@ -219,6 +184,7 @@ struct mddev_dev *load_containers(void)
 struct createinfo createinfo = {
        .autof = 2, /* by default, create devices with standard names */
        .symlinks = 1,
+       .names = 0, /* By default, stick with numbered md devices. */
 #ifdef DEBIAN
        .gid = 6, /* disk */
        .mode = 0660,
@@ -334,6 +300,10 @@ static void createline(char *line)
                        createinfo.symlinks = 1;
                else if  (strncasecmp(w, "symlinks=no", 11) == 0)
                        createinfo.symlinks = 0;
+               else if (strncasecmp(w, "names=yes", 12) == 0)
+                       createinfo.names = 1;
+               else if  (strncasecmp(w, "names=no", 11) == 0)
+                       createinfo.names = 0;
                else {
                        pr_err("unrecognised word on CREATE line: %s\n",
                                w);
@@ -412,7 +382,7 @@ void arrayline(char *line)
                        if (strcasecmp(w, "<ignore>") == 0 ||
                            strncmp(w, "/dev/md/", 8) == 0 ||
                            (w[0] != '/' && w[0] != '<') ||
-                           (strncmp(w, "/dev/md", 7) == 0 && 
+                           (strncmp(w, "/dev/md", 7) == 0 &&
                             is_number(w+7)) ||
                            (strncmp(w, "/dev/md_d", 9) == 0 &&
                             is_number(w+9))
@@ -563,7 +533,6 @@ void mailfromline(char *line)
        }
 }
 
-
 static char *alert_program = NULL;
 void programline(char *line)
 {
@@ -884,9 +853,9 @@ struct mddev_dev *conf_get_devs()
        if (flags & GLOB_APPEND) {
                for (i=0; i<globbuf.gl_pathc; i++) {
                        struct mddev_dev *t = xmalloc(sizeof(*t));
+                       memset(t, 0, sizeof(*t));
                        t->devname = xstrdup(globbuf.gl_pathv[i]);
                        t->next = dlist;
-                       t->used = 0;
                        dlist = t;
 /*     printf("one dev is %s\n", t->devname);*/
                }
@@ -982,7 +951,6 @@ int devname_matches(char *name, char *match)
        else if (strncmp(match, "/dev/", 5) == 0)
                match += 5;
 
-
        if (strncmp(name, "md", 2) == 0 &&
            isdigit(name[2]))
                name += 2;