1
0
Fork 0

Merging upstream version 4.3+20241108.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-14 06:11:53 +01:00
parent 1e24552bfc
commit 60ccb5b596
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
64 changed files with 2015 additions and 1768 deletions

110
config.c
View file

@ -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;
}
free_mdstat(mdstat);
map_free(map);
return rv;
d->next = dev_list;
dev_list = d;
}
free_mdstat(mdstat);
map_free(map_list);
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);