- 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);
- }
- if (strcmp(update, "summaries") == 0) {
- /* set nr_disks, active_disks, working_disks,
- * failed_disks, spare_disks based on disks[]
- * array in superblock.
- * Also make sure extra slots aren't 'failed'
- */
- super.nr_disks = super.active_disks =
- super.working_disks = super.failed_disks =
- super.spare_disks = 0;
- for (i=0; i < MD_SB_DISKS ; i++)
- if (super.disks[i].major ||
- super.disks[i].minor) {
- int state = super.disks[i].state;
- if (state & (1<<MD_DISK_REMOVED))
- continue;
- super.nr_disks++;
- if (state & (1<<MD_DISK_ACTIVE))
- super.active_disks++;
- if (state & (1<<MD_DISK_FAULTY))
- super.failed_disks++;
- else
- super.working_disks++;
- if (state == 0)
- super.spare_disks++;
- } else if (i >= super.raid_disks && super.disks[i].number == 0)
- super.disks[i].state = 0;
+ int dfd;
+ /* prepare useful information in info structures */
+ struct stat stb2;
+ struct supertype *tst;
+ fstat(mdfd, &stb2);
+
+ 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);