summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2006-05-23 04:57:04 +0000
committerNeil Brown <neilb@suse.de>2006-05-23 04:57:04 +0000
commitc4f12c134069e191b08074b4ed7ba689d0827d11 (patch)
tree292b9970ee244976b9ba1218c0bd1314532611f9
parente5eac01f3d52ceb932445f90c0aaa86f244e26e7 (diff)
downloadmdadm-c4f12c134069e191b08074b4ed7ba689d0827d11.tar.gz
mdadm-c4f12c134069e191b08074b4ed7ba689d0827d11.tar.xz
mdadm-c4f12c134069e191b08074b4ed7ba689d0827d11.zip
Allow --update=name to update the name during assembly.
Signed-off-by: Neil Brown <neilb@suse.de>
-rw-r--r--Assemble.c2
-rw-r--r--mdadm.88
-rw-r--r--mdadm.c2
-rw-r--r--super1.c13
4 files changed, 24 insertions, 1 deletions
diff --git a/Assemble.c b/Assemble.c
index 30cb1aa..1dc0ffc 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -225,7 +225,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
devname);
continue;
}
- if (ident->name[0] &&
+ if (ident->name[0] && (!update || strcmp(update, "name")!= 0) &&
(!super || strncmp(info.name, ident->name, 32)!=0)) {
if ((inargv && verbose >= 0) || verbose > 0)
fprintf(stderr, Name ": %s has wrong name.\n",
diff --git a/mdadm.8 b/mdadm.8
index 9c113f0..132052a 100644
--- a/mdadm.8
+++ b/mdadm.8
@@ -650,6 +650,7 @@ argument given to this flag can be one of
.BR sparc2.2 ,
.BR summaries ,
.BR uuid ,
+.BR name ,
.BR resync ,
.BR byteorder ,
or
@@ -682,6 +683,13 @@ be used to help identify the devices in the array.
If no "--uuid" is given, a random uuid is chosen.
The
+.B name
+option will change the
+.I name
+of the array as stored in the superblock. This is only supported for
+version-1 superblocks.
+
+The
.B resync
option will cause the array to be marked
.I dirty
diff --git a/mdadm.c b/mdadm.c
index 880fa94..42fcf07 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -566,6 +566,8 @@ int main(int argc, char *argv[])
continue;
if (strcmp(update, "uuid")==0)
continue;
+ if (strcmp(update, "name")==0)
+ continue;
if (strcmp(update, "byteorder")==0) {
if (ss) {
fprintf(stderr, Name ": must not set metadata type with --update=byteorder.\n");
diff --git a/super1.c b/super1.c
index 533929a..2ccda5d 100644
--- 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);