summaryrefslogtreecommitdiffstats
path: root/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'config.c')
-rw-r--r--config.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/config.c b/config.c
index eeedd0c..450880e 100644
--- a/config.c
+++ b/config.c
@@ -120,6 +120,18 @@ int match_keyword(char *word)
}
/**
+ * 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;