1
0
Fork 0

Merging upstream version 4.2+20230508.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-14 06:05:31 +01:00
parent 8119c4e7dc
commit 8f10cd7248
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
27 changed files with 335 additions and 232 deletions

View file

@ -119,6 +119,18 @@ int match_keyword(char *word)
return -1;
}
/**
* is_devname_ignore() - check if &devname is a special "<ignore>" keyword.
*/
bool is_devname_ignore(char *devname)
{
static const char keyword[] = "<ignore>";
if (strcasecmp(devname, keyword) == 0)
return true;
return false;
}
/**
* ident_init() - Set defaults.
* @ident: ident pointer, not NULL.
@ -373,17 +385,6 @@ void devline(char *line)
struct mddev_ident *mddevlist = NULL;
struct mddev_ident **mddevlp = &mddevlist;
static int is_number(char *w)
{
/* check if there are 1 or more digits and nothing else */
int digits = 0;
while (*w && isdigit(*w)) {
digits++;
w++;
}
return (digits && ! *w);
}
void arrayline(char *line)
{
char *w;
@ -404,13 +405,11 @@ void arrayline(char *line)
* <ignore>
* or anything that doesn't start '/' or '<'
*/
if (strcasecmp(w, "<ignore>") == 0 ||
strncmp(w, "/dev/md/", 8) == 0 ||
if (is_devname_ignore(w) == true ||
strncmp(w, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0 ||
(w[0] != '/' && w[0] != '<') ||
(strncmp(w, "/dev/md", 7) == 0 &&
is_number(w + 7)) ||
(strncmp(w, "/dev/md_d", 9) == 0 &&
is_number(w + 9))) {
is_devname_md_numbered(w) == true ||
is_devname_md_d_numbered(w) == true) {
/* This is acceptable */;
if (mis.devname)
pr_err("only give one device per ARRAY line: %s and %s\n",
@ -571,7 +570,7 @@ void homehostline(char *line)
char *w;
for (w = dl_next(line); w != line; w = dl_next(w)) {
if (strcasecmp(w, "<ignore>") == 0)
if (is_devname_ignore(w) == true)
require_homehost = 0;
else if (home_host == NULL) {
if (strcasecmp(w, "<none>") == 0)
@ -1102,13 +1101,13 @@ int devname_matches(char *name, char *match)
* mdNN with NN
* then just strcmp
*/
if (strncmp(name, "/dev/md/", 8) == 0)
name += 8;
if (strncmp(name, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0)
name += DEV_MD_DIR_LEN;
else if (strncmp(name, "/dev/", 5) == 0)
name += 5;
if (strncmp(match, "/dev/md/", 8) == 0)
match += 8;
if (strncmp(match, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0)
match += DEV_MD_DIR_LEN;
else if (strncmp(match, "/dev/", 5) == 0)
match += 5;