]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
config: restore the possibility of a NULL homehost
authorNeilBrown <neilb@suse.de>
Tue, 10 May 2011 06:17:12 +0000 (16:17 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 10 May 2011 06:17:12 +0000 (16:17 +1000)
As homehost defaults to the system name it is not possible to specify
a NULL homehost.

This patch restored this ability with either --homehost="" or
--homehost="<none>".

This allows the creation of v1.x arrays without a "hostname:"
prefix in the name.

Signed-off-by: NeilBrown <neilb@suse.de>
config.c
mdadm.c
mdadm.conf.5
super0.c
super1.c

index 0dbe61ed30ab03c8382e1b758d99da0d4c94f83d..ad75411cf68b94aeef79d02f3c2dbf7b83ceb121 100644 (file)
--- a/config.c
+++ b/config.c
@@ -589,9 +589,12 @@ void homehostline(char *line)
        for (w=dl_next(line); w != line ; w=dl_next(w)) {
                if (strcasecmp(w, "<ignore>")==0)
                        require_homehost = 0;
-               else if (home_host == NULL)
-                       home_host = strdup(w);
-               else
+               else if (home_host == NULL) {
+                       if (strcasecmp(w, "<none>")==0)
+                               home_host = strdup("");
+                       else
+                               home_host = strdup(w);
+               }else
                        fprintf(stderr, Name ": excess host name on HOMEHOST line: %s - ignored\n",
                                w);
        }
diff --git a/mdadm.c b/mdadm.c
index ec05e6e85decc61ec1820cd7ac5d2af5401d61d1..96d32b53059f0f5dac98ab8ae4e103ae977e3b75 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -1167,12 +1167,16 @@ int main(int argc, char *argv[])
 
        if (homehost == NULL)
                homehost = conf_get_homehost(&require_homehost);
-       if (homehost == NULL || strcmp(homehost, "<system>")==0) {
+       if (homehost == NULL || strcasecmp(homehost, "<system>")==0) {
                if (gethostname(sys_hostname, sizeof(sys_hostname)) == 0) {
                        sys_hostname[sizeof(sys_hostname)-1] = 0;
                        homehost = sys_hostname;
                }
        }
+       if (homehost && (!homehost[0] || strcasecmp(homehost, "<none>") == 0)) {
+               homehost = NULL;
+               require_homehost = 0;
+       }
 
        if ((mode != MISC || devmode != 'E') &&
            geteuid() != 0) {
index 65b00293723c7a5834f400456b4391293a7ebef4..9f31c734a1e287197e70a619fa8bc7f6482ebaec 100644 (file)
@@ -339,14 +339,15 @@ line gives a default value for the
 .B \-\-homehost=
 option to mdadm.  There should normally be only one other word on the line.
 It should either be a host name, or one of the special words
-.B <system>
+.BR <system>,
+.B <none>
 and
 .BR <ignore> .
 If
 .B <system>
 is given, then the
 .BR gethostname ( 2 )
-systemcall is used to get the host name.
+systemcall is used to get the host name.  This is the default.
 
 If
 .B <ignore>
@@ -362,6 +363,12 @@ more that one other word on the
 .B HOMEHOST
 line.
 
+If
+.B <none>
+is given, then the default of using
+.BR gethostname ( 2 )
+is over-ridden and no homehost name is assumed.
+
 When arrays are created, this host name will be stored in the
 metadata.  When arrays are assembled using auto-assembly, arrays which
 do not record the correct homehost name in their metadata will be
index 3ae236a82d57b9d8fd7efff4a96b7e5d1d6e3ba8..2c27e1e196c951b6ed0d23cf5bdce05a65b12304 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -541,7 +541,7 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
                sb->state &= ~(1<<MD_SB_CLEAN);
                sb->recovery_cp = 0;
        } else if (strcmp(update, "homehost") == 0 &&
-           homehost) {
+                  homehost) {
                uuid_set = 0;
                update = "uuid";
                info->uuid[0] = sb->set_uuid0;
index 79bb4d0cdcaf10c2dd95840e283e4f06eb7983af..9ba1ded4e00d152d28d413af20eeeb3c002559e3 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -772,7 +772,7 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
        } else if (strcmp(update, "no-bitmap") == 0) {
                sb->feature_map &= ~__cpu_to_le32(MD_FEATURE_BITMAP_OFFSET);
        } else if (strcmp(update, "homehost") == 0 &&
-           homehost) {
+                  homehost) {
                char *c;
                update = "name";
                c = strchr(sb->set_name, ':');