summaryrefslogtreecommitdiffstats
path: root/super1.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2013-02-07 01:51:21 +0100
committerNeilBrown <neilb@suse.de>2013-02-10 05:40:42 +0100
commitdef1133297d8f619c8fd644d6d8c6633ddcaa929 (patch)
tree5a8375edf867479695e2aeb8d9d170e8d742b175 /super1.c
parentAvoid using BLKFLSBUF. (diff)
downloadmdadm-def1133297d8f619c8fd644d6d8c6633ddcaa929.tar.xz
mdadm-def1133297d8f619c8fd644d6d8c6633ddcaa929.zip
make --update=homehost work again
Commit 1e2b276535cea41c348292a019bdda8a58cb1679 (Report error in --update string is not recognised) broke homehost updating functionality because it depended on each string comparison being done even after we already found a match. Make it work again by restructuring code. Reported-by: (and original version by) Justin Maggard <jmaggard10@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'super1.c')
-rw-r--r--super1.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/super1.c b/super1.c
index fe83af5b..4e380d98 100644
--- a/super1.c
+++ b/super1.c
@@ -885,6 +885,21 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
int rv = 0;
struct mdp_superblock_1 *sb = st->sb;
+ if (strcmp(update, "homehost") == 0 &&
+ homehost) {
+ /* Note that 'homehost' is special as it is really
+ * a "name" update.
+ */
+ 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[32] = 0;
+ }
+
if (strcmp(update, "force-one")==0) {
/* Not enough devices for a working array,
* so bring this one up-to-date
@@ -1037,16 +1052,6 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
sb->bblog_shift = 0;
sb->bblog_offset = 0;
}
- } else 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[32] = 0;
} else if (strcmp(update, "name") == 0) {
if (info->name[0] == 0)
sprintf(info->name, "%d", info->array.md_minor);