/* prepare useful information in info structures */
struct stat stb2;
struct supertype *tst;
+ int err;
fstat(mdfd, &stb2);
if (strcmp(update, "uuid")==0 &&
strcpy(content->name, ident->name);
content->array.md_minor = minor(stb2.st_rdev);
- tst->ss->update_super(tst, content, update,
- devname, verbose,
- ident->uuid_set, homehost);
+ if (strcmp(update, "byteorder") == 0)
+ err = 0;
+ else
+ err = tst->ss->update_super(tst, content, update,
+ devname, verbose,
+ ident->uuid_set,
+ homehost);
+ if (err < 0) {
+ fprintf(stderr,
+ Name ": --update=%s not understood"
+ " for %s metadata\n",
+ update, tst->ss->name);
+ tst->ss->free_super(tst);
+ free(tst);
+ close(mdfd);
+ close(dfd);
+ return 1;
+ }
if (strcmp(update, "uuid")==0 &&
!ident->uuid_set) {
ident->uuid_set = 1;
memcpy(ident->uuid, content->uuid, 16);
}
- if (dfd < 0)
- fprintf(stderr, Name ": Cannot open %s for superblock update\n",
- devname);
- else if (tst->ss->store_super(tst, dfd))
+ if (tst->ss->store_super(tst, dfd))
fprintf(stderr, Name ": Could not re-write superblock on %s.\n",
devname);
- if (dfd >= 0)
- close(dfd);
+ close(dfd);
if (strcmp(update, "uuid")==0 &&
ident->bitmap_fd >= 0 && !bitmap_done) {
if (strcmp(update, "grow") == 0) {
/* FIXME */
- }
- if (strcmp(update, "resync") == 0) {
+ } else if (strcmp(update, "resync") == 0) {
// info->resync_checkpoint = 0;
- }
- /* We ignore UUID updates as they make even less sense
- * with DDF
- */
- if (strcmp(update, "homehost") == 0) {
+ } else if (strcmp(update, "homehost") == 0) {
/* homehost is stored in controller->vendor_data,
* or it is when we are the vendor
*/
// if (info->vendor_is_local)
// strcpy(ddf->controller.vendor_data, homehost);
- }
- if (strcmp(update, "name") == 0) {
+ rv = -1;
+ } if (strcmp(update, "name") == 0) {
/* name is stored in virtual_entry->name */
// memset(ve->name, ' ', 16);
// strncpy(ve->name, info->name, 16);
- }
- if (strcmp(update, "_reshape_progress") == 0) {
+ rv = -1;
+ } if (strcmp(update, "_reshape_progress") == 0) {
/* We don't support reshape yet */
- }
+ } else
+ rv = -1;
// update_all_csum(ddf);
mpb = super->anchor;
if (strcmp(update, "uuid") == 0 && uuid_set && !info->update_private)
- fprintf(stderr,
- Name ": '--uuid' not supported for imsm metadata\n");
+ rv = -1;
else if (strcmp(update, "uuid") == 0 && uuid_set && info->update_private) {
mpb->orig_family_num = *((__u32 *) info->update_private);
rv = 0;
} else if (strcmp(update, "assemble") == 0)
rv = 0;
else
- fprintf(stderr,
- Name ": '--update=%s' not supported for imsm metadata\n",
- update);
+ rv = -1;
/* successful update? recompute checksum */
if (rv == 0)
if (verbose >= 0)
fprintf (stderr, Name ": adjusting superblock of %s for 2.2/sparc compatability.\n",
devname);
- }
- if (strcmp(update, "super-minor") ==0) {
+ } else if (strcmp(update, "super-minor") ==0) {
sb->md_minor = info->array.md_minor;
if (verbose > 0)
fprintf(stderr, Name ": updating superblock of %s with minor number %d\n",
devname, info->array.md_minor);
- }
- if (strcmp(update, "summaries") == 0) {
+ } else if (strcmp(update, "summaries") == 0) {
unsigned int i;
/* set nr_disks, active_disks, working_disks,
* failed_disks, spare_disks based on disks[]
sb->spare_disks++;
} else if (i >= sb->raid_disks && sb->disks[i].number == 0)
sb->disks[i].state = 0;
- }
- if (strcmp(update, "force-one")==0) {
+ } else if (strcmp(update, "force-one")==0) {
/* Not enough devices for a working array, so
* bring this one up-to-date.
*/
if (sb->events_hi != ehi ||
sb->events_lo != elo)
rv = 1;
- }
- if (strcmp(update, "force-array")==0) {
+ } else if (strcmp(update, "force-array")==0) {
/* degraded array and 'force' requested, so
* maybe need to mark it 'clean'
*/
sb->state |= (1 << MD_SB_CLEAN);
rv = 1;
}
- }
- if (strcmp(update, "assemble")==0) {
+ } else if (strcmp(update, "assemble")==0) {
int d = info->disk.number;
int wonly = sb->disks[d].state & (1<<MD_DISK_WRITEMOSTLY);
int mask = (1<<MD_DISK_WRITEMOSTLY);
sb->disks[d].state = info->disk.state | wonly;
rv = 1;
}
- }
- if (strcmp(update, "linear-grow-new") == 0) {
+ } else if (strcmp(update, "linear-grow-new") == 0) {
memset(&sb->disks[info->disk.number], 0, sizeof(sb->disks[0]));
sb->disks[info->disk.number].number = info->disk.number;
sb->disks[info->disk.number].major = info->disk.major;
sb->disks[info->disk.number].raid_disk = info->disk.raid_disk;
sb->disks[info->disk.number].state = info->disk.state;
sb->this_disk = sb->disks[info->disk.number];
- }
- if (strcmp(update, "linear-grow-update") == 0) {
+ } else if (strcmp(update, "linear-grow-update") == 0) {
sb->raid_disks = info->array.raid_disks;
sb->nr_disks = info->array.nr_disks;
sb->active_disks = info->array.active_disks;
sb->disks[info->disk.number].minor = info->disk.minor;
sb->disks[info->disk.number].raid_disk = info->disk.raid_disk;
sb->disks[info->disk.number].state = info->disk.state;
- }
- if (strcmp(update, "resync") == 0) {
+ } else if (strcmp(update, "resync") == 0) {
/* make sure resync happens */
sb->state &= ~(1<<MD_SB_CLEAN);
sb->recovery_cp = 0;
- }
- if (strcmp(update, "homehost") == 0 &&
+ } else if (strcmp(update, "homehost") == 0 &&
homehost) {
uuid_set = 0;
update = "uuid";
info->uuid[0] = sb->set_uuid0;
info->uuid[1] = sb->set_uuid1;
- }
- if (strcmp(update, "uuid") == 0) {
+ } else if (strcmp(update, "uuid") == 0) {
if (!uuid_set && homehost) {
char buf[20];
char *hash = sha1_buffer(homehost,
bm = (struct bitmap_super_s*)(sb+1);
uuid_from_super0(st, (int*)bm->uuid);
}
- }
- if (strcmp(update, "_reshape_progress")==0)
+ } else if (strcmp(update, "_reshape_progress")==0)
sb->reshape_position = info->reshape_progress;
+ else
+ rv = -1;
sb->sb_csum = calc_sb0_csum(sb);
return rv;
if (sb->events != __cpu_to_le64(info->events))
rv = 1;
sb->events = __cpu_to_le64(info->events);
- }
- if (strcmp(update, "force-array")==0) {
+ } else if (strcmp(update, "force-array")==0) {
/* Degraded array and 'force' requests to
* maybe need to mark it 'clean'.
*/
rv = 1;
sb->resync_offset = MaxSector;
}
- }
- if (strcmp(update, "assemble")==0) {
+ } else if (strcmp(update, "assemble")==0) {
int d = info->disk.number;
int want;
if (info->disk.state == 6)
sb->dev_roles[d] = want;
rv = 1;
}
- }
- if (strcmp(update, "linear-grow-new") == 0) {
+ } else if (strcmp(update, "linear-grow-new") == 0) {
unsigned int i;
int rfd, fd;
unsigned int max = __le32_to_cpu(sb->max_dev);
ds - __le64_to_cpu(sb->data_offset));
}
}
- }
- if (strcmp(update, "linear-grow-update") == 0) {
+ } else if (strcmp(update, "linear-grow-update") == 0) {
sb->raid_disks = __cpu_to_le32(info->array.raid_disks);
sb->dev_roles[info->disk.number] =
__cpu_to_le16(info->disk.raid_disk);
- }
- if (strcmp(update, "resync") == 0) {
+ } else if (strcmp(update, "resync") == 0) {
/* make sure resync happens */
sb->resync_offset = 0ULL;
- }
- if (strcmp(update, "uuid") == 0) {
+ } else if (strcmp(update, "uuid") == 0) {
copy_uuid(sb->set_uuid, info->uuid, super1.swapuuid);
if (__le32_to_cpu(sb->feature_map)&MD_FEATURE_BITMAP_OFFSET) {
bm = (struct bitmap_super_s*)(st->sb+1024);
memcpy(bm->uuid, sb->set_uuid, 16);
}
- }
- if (strcmp(update, "homehost") == 0 &&
+ } else if (strcmp(update, "homehost") == 0 &&
homehost) {
char *c;
update = "name";
else
strncpy(info->name, sb->set_name, 32);
info->name[32] = 0;
- }
- if (strcmp(update, "name") == 0) {
+ } else 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));
strcat(sb->set_name, info->name);
} else
strcpy(sb->set_name, info->name);
- }
- if (strcmp(update, "devicesize") == 0 &&
+ } else if (strcmp(update, "devicesize") == 0 &&
__le64_to_cpu(sb->super_offset) <
__le64_to_cpu(sb->data_offset)) {
/* set data_size to device size less data_offset */
misc->device_size - __le64_to_cpu(sb->data_offset));
printf("Size is %llu\n", (unsigned long long)
__le64_to_cpu(sb->data_size));
- }
- if (strcmp(update, "_reshape_progress")==0)
+ } else if (strcmp(update, "_reshape_progress")==0)
sb->reshape_position = __cpu_to_le64(info->reshape_progress);
+ else
+ rv = -1;
sb->sb_csum = calc_sb_1_csum(sb);
return rv;