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;
+ struct conf_dev *next;
+ char *name;
} *cdevlist = NULL;
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);
struct mdstat_ent *ent;
struct mddev_dev *d;
struct mddev_dev *rv = NULL;
+ struct map_ent *map = NULL, *me;
if (!mdstat)
return NULL;
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;
}
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,
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);
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))
}
}
-
static char *alert_program = NULL;
void programline(char *line)
{
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);*/
}
int match_oneof(char *devices, char *devname)
{
- /* check if one of the comma separated patterns in devices
- * matches devname
- */
-
- while (devices && *devices) {
- char patn[1024];
- char *p = devices;
- devices = strchr(devices, ',');
- if (!devices)
- devices = p + strlen(p);
- if (devices-p < 1024) {
- strncpy(patn, p, devices-p);
- patn[devices-p] = 0;
- if (fnmatch(patn, devname, FNM_PATHNAME)==0)
- return 1;
+ /* check if one of the comma separated patterns in devices
+ * matches devname
+ */
+
+ while (devices && *devices) {
+ char patn[1024];
+ char *p = devices;
+ devices = strchr(devices, ',');
+ if (!devices)
+ devices = p + strlen(p);
+ if (devices-p < 1024) {
+ strncpy(patn, p, devices-p);
+ patn[devices-p] = 0;
+ if (fnmatch(patn, devname, FNM_PATHNAME)==0)
+ return 1;
+ }
+ if (*devices == ',')
+ devices++;
}
- if (*devices == ',')
- devices++;
- }
- return 0;
+ return 0;
}
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;
int conf_name_is_free(char *name)
{
- /* Check if this name is already take by an ARRAY entry in
+ /* Check if this name is already taken by an ARRAY entry in
* the config file.
* It can be taken either by a match on devname, name, or
* even super-minor.
for (a1 = array_list; a1; a1 = a1->next) {
if (!a1->devname)
continue;
+ if (strcmp(a1->devname, "<ignore>") == 0)
+ continue;
for (a2 = a1->next; a2; a2 = a2->next) {
if (!a2->devname)
continue;