summaryrefslogtreecommitdiffstats
path: root/Assemble.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2005-12-05 05:56:33 +0000
committerNeil Brown <neilb@suse.de>2005-12-05 05:56:33 +0000
commit7d99579f6a52fbf575e4707121ece51d0672277b (patch)
tree61745ca11734259875fa35139858875fb9185d79 /Assemble.c
parentee04451c56f5bc39a77515e2e51897ac1fc15104 (diff)
downloadmdadm-7d99579f6a52fbf575e4707121ece51d0672277b.tar.gz
mdadm-7d99579f6a52fbf575e4707121ece51d0672277b.tar.xz
mdadm-7d99579f6a52fbf575e4707121ece51d0672277b.zip
Support updating of uuid during --assemble.
Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'Assemble.c')
-rw-r--r--Assemble.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/Assemble.c b/Assemble.c
index 9fbc53e..0555854 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -219,7 +219,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
}
if (dfd >= 0) close(dfd);
- if (ident->uuid_set &&
+ if (ident->uuid_set && (!update && strcmp(update, "uuid")!= 0) &&
(!super || same_uuid(info.uuid, ident->uuid, tst->ss->swapuuid)==0)) {
if ((inargv && verbose >= 0) || verbose > 0)
fprintf(stderr, Name ": %s has wrong uuid.\n",
@@ -281,7 +281,21 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
struct stat stb2;
fstat(mdfd, &stb2);
info.array.md_minor = minor(stb2.st_rdev);
-
+
+ if (strcmp(update, "uuid")==0 &&
+ !ident->uuid_set) {
+ int rfd;
+ if ((rfd = open("/dev/urandom", O_RDONLY)) < 0 ||
+ read(rfd, ident->uuid, 16) != 16) {
+ *(__u32*)(ident->uuid) = random();
+ *(__u32*)(ident->uuid+1) = random();
+ *(__u32*)(ident->uuid+2) = random();
+ *(__u32*)(ident->uuid+3) = random();
+ }
+ if (rfd >= 0) close(rfd);
+ ident->uuid_set = 1;
+ }
+ memcpy(info.uuid, ident->uuid, 16);
st->ss->update_super(&info, super, update, devname, verbose);
dfd = dev_open(devname, O_RDWR|O_EXCL);