]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Support --update=homehost to allow updating of homehost information.
authorNeil Brown <neilb@suse.de>
Tue, 23 May 2006 05:16:32 +0000 (05:16 +0000)
committerNeil Brown <neilb@suse.de>
Tue, 23 May 2006 05:16:32 +0000 (05:16 +0000)
Signed-off-by: Neil Brown <neilb@suse.de>
mdadm.8
mdadm.c
super0.c
super1.c

diff --git a/mdadm.8 b/mdadm.8
index 132052ad23ff1bf295a0fd881f2414d4f72510db..ebabaa4f3b9ddbb7544f9d7a53f168ba46c22421 100644 (file)
--- a/mdadm.8
+++ b/mdadm.8
@@ -651,6 +651,7 @@ argument given to this flag can be one of
 .BR summaries ,
 .BR uuid ,
 .BR name ,
+.BR homehost ,
 .BR resync ,
 .BR byteorder ,
 or
@@ -689,6 +690,14 @@ option will change the
 of the array as stored in the superblock.  This is only supported for
 version-1 superblocks.
 
+The
+.B homehost
+option will change the
+.I homehost
+as recorded in the superblock.  For version-0 superblocks, this is the
+same as updating the UUID.
+For version-1 superblocks, this involves updating the name.
+
 The
 .B resync
 option will cause the array to be marked
diff --git a/mdadm.c b/mdadm.c
index 42fcf0762a8a207480c2c9ee099a81900df0a785..0df73691fb8b0117fd925023bda393e5b59a45e3 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -568,6 +568,8 @@ int main(int argc, char *argv[])
                                continue;
                        if (strcmp(update, "name")==0)
                                continue;
+                       if (strcmp(update, "homehost")==0)
+                               continue;
                        if (strcmp(update, "byteorder")==0) {
                                if (ss) {
                                        fprintf(stderr, Name ": must not set metadata type with --update=byteorder.\n");
index d21032f3a4265760051bafa3bce764ad990e0abb..85e54fc9bc7c5fa1a84fcab177fcbcb66af08f47 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -442,6 +442,13 @@ static int update_super0(struct mdinfo *info, void *sbv, char *update,
                sb->state &= ~(1<<MD_SB_CLEAN);
                sb->recovery_cp = 0;
        }
+       if (strcmp(update, "homehost") == 0 &&
+           homehost) {
+               uuid_set = 0;
+               update = "uuid";
+               info->uuid[0] = sb->set_uuid0;
+               info->uuid[1] = sb->set_uuid1;
+       }
        if (strcmp(update, "uuid") == 0) {
                if (!uuid_set && homehost) {
                        unsigned char *hash = SHA1((unsigned char*)homehost,
index 2ccda5dab2eaafaf11d2dd29c0021e1d8bae231e..b24bceae2ea291f6461638c7fe4487d5f349dac2 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -496,6 +496,17 @@ static int update_super1(struct mdinfo *info, void *sbv, char *update,
                        memcpy(bm->uuid, info->uuid, 16);
                }
        }
+       if (strcmp(update, "homehost") == 0 &&
+           homehost) {
+               char *c;
+               update = "name";
+               c = strchr(sb->set_name, ':');
+               if (c)
+                       strncpy(info->name, c+1, 31 - (c-sb->set_name));
+               else
+                       strncpy(info->name, sb->set_name, 32);
+               info->name[33] = 0;
+       }
        if (strcmp(update, "name") == 0) {
                if (info->name[0] == 0)
                        sprintf(info->name, "%d", info->array.md_minor);