]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super1.c
Allow --update=name to update the name during assembly.
[thirdparty/mdadm.git] / super1.c
index 533929a303f486654b8ad735f14a119058755166..2ccda5dab2eaafaf11d2dd29c0021e1d8bae231e 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -496,6 +496,19 @@ static int update_super1(struct mdinfo *info, void *sbv, char *update,
                        memcpy(bm->uuid, info->uuid, 16);
                }
        }
+       if (strcmp(update, "name") == 0) {
+               if (info->name[0] == 0)
+                       sprintf(info->name, "%d", info->array.md_minor);
+               memset(sb->set_name, 0, sizeof(sb->set_name));
+               if (homehost &&
+                   strchr(info->name, ':') == NULL &&
+                   strlen(homehost)+1+strlen(info->name) < 32) {
+                       strcpy(sb->set_name, homehost);
+                       strcat(sb->set_name, ":");
+                       strcat(sb->set_name, info->name);
+               } else
+                       strcpy(sb->set_name, info->name);
+       }
        if (strcmp(update, "_reshape_progress")==0)
                sb->reshape_position = __cpu_to_le64(info->reshape_progress);