- if (strcmp(update, "sparc2.2")==0 ) {
- /* 2.2 sparc put the events in the wrong place
- * So we copy the tail of the superblock
- * up 4 bytes before continuing
- */
- __u32 *sb32 = (__u32*)&super;
- memcpy(sb32+MD_SB_GENERIC_CONSTANT_WORDS+7,
- sb32+MD_SB_GENERIC_CONSTANT_WORDS+7+1,
- (MD_SB_WORDS - (MD_SB_GENERIC_CONSTANT_WORDS+7+1))*4);
- fprintf (stderr, Name ": adjusting superblock of %s for 2.2/sparc compatability.\n",
- devname);
- }
- if (strcmp(update, "super-minor") ==0) {
- struct stat stb2;
- fstat(mdfd, &stb2);
- super.md_minor = MINOR(stb2.st_rdev);
- if (verbose)
- fprintf(stderr, Name ": updating superblock of %s with minor number %d\n",
- devname, super.md_minor);
+ /* prepare useful information in info structures */
+ 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;