* - initialising a new superblock
* - printing the superblock for --examine
* - printing part of the superblock for --detail
- * .. other stuff
+ * .. other stuff
*/
void super0_swap_endian(struct mdp_superblock_s *sb)
{
/* as super0 superblocks are host-endian, it is sometimes
- * useful to be able to swap the endianness
+ * useful to be able to swap the endianness
* as (almost) everything is u32's we byte-swap every 4byte
* number.
* We then also have to swap the events_hi and events_lo
#ifndef MDASSEMBLE
-static void examine_super0(void *sbv, char *homehost)
+static void examine_super0(struct supertype *st, void *sbv, char *homehost)
{
mdp_super_t *sb = sbv;
time_t atime;
}
}
-static void brief_examine_super0(void *sbv)
+static void brief_examine_super0(struct supertype *st, void *sbv)
{
mdp_super_t *sb = sbv;
char *c=map_num(pers, sb->level);
printf("\n");
}
-static void detail_super0(void *sbv, char *homehost)
+static void detail_super0(struct supertype *st, void *sbv, char *homehost)
{
mdp_super_t *sb = sbv;
printf(" UUID : ");
printf("\n Events : %d.%d\n\n", sb->events_hi, sb->events_lo);
}
-static void brief_detail_super0(void *sbv)
+static void brief_detail_super0(struct supertype *st, void *sbv)
{
mdp_super_t *sb = sbv;
printf(" UUID=");
printf("%08x", sb->set_uuid0);
}
-static void export_super0(void *sbv)
+static void export_super0(struct supertype *st, void *sbv)
{
mdp_super_t *sb = sbv;
printf("MD_UUID=");
}
#endif
-static int match_home0(void *sbv, char *homehost)
+static int match_home0(struct supertype *st, void *sbv, char *homehost)
{
mdp_super_t *sb = sbv;
char buf[20];
return (memcmp(&sb->set_uuid2, hash, 8)==0);
}
-static void uuid_from_super0(int uuid[4], void * sbv)
+static void uuid_from_super0(struct supertype *st, int uuid[4], void * sbv)
{
mdp_super_t *super = sbv;
uuid[0] = super->set_uuid0;
}
}
-static void getinfo_super0(struct mdinfo *info, void *sbv)
+static void getinfo_super0(struct supertype *st, struct mdinfo *info, void *sbv)
{
mdp_super_t *sb = sbv;
int working = 0;
info->events = md_event(sb);
info->data_offset = 0;
- uuid_from_super0(info->uuid, sbv);
+ uuid_from_super0(st, info->uuid, sbv);
if (sb->minor_version > 90 && (sb->reshape_position+1) != 0) {
info->reshape_active = 1;
}
-static int update_super0(struct mdinfo *info, void *sbv, char *update,
+static int update_super0(struct supertype *st, struct mdinfo *info,
+ void *sbv, char *update,
char *devname, int verbose,
int uuid_set, char *homehost)
{
if (strcmp(update, "summaries") == 0) {
int i;
/* set nr_disks, active_disks, working_disks,
- * failed_disks, spare_disks based on disks[]
+ * failed_disks, spare_disks based on disks[]
* array in superblock.
* Also make sure extra slots aren't 'failed'
*/
sb->nr_disks = sb->active_disks =
sb->working_disks = sb->failed_disks =
sb->spare_disks = 0;
- for (i=0; i < MD_SB_DISKS ; i++)
+ for (i=0; i < MD_SB_DISKS ; i++)
if (sb->disks[i].major ||
sb->disks[i].minor) {
int state = sb->disks[i].state;
if (sb->state & (1<<MD_SB_BITMAP_PRESENT)) {
struct bitmap_super_s *bm;
bm = (struct bitmap_super_s*)(sb+1);
- uuid_from_super0((int*)bm->uuid, sbv);
+ uuid_from_super0(st, (int*)bm->uuid, sbv);
}
}
if (strcmp(update, "_reshape_progress")==0)
}
/* Add a device to the superblock being created */
-static void add_to_super0(void *sbv, mdu_disk_info_t *dinfo)
+static void add_to_super0(struct supertype *st, void *sbv, mdu_disk_info_t *dinfo)
{
mdp_super_t *sb = sbv;
mdp_disk_t *dk = &sb->disks[dinfo->number];
return 0;
}
- uuid_from_super0(uuid1, first);
- uuid_from_super0(uuid2, second);
+ uuid_from_super0(NULL, uuid1, first);
+ uuid_from_super0(NULL, uuid2, second);
if (!same_uuid(uuid1, uuid2, 0))
return 2;
if (first->major_version != second->major_version ||
mdp_super_t *super;
int uuid[4];
struct bitmap_super_s *bsb;
-
+
if (!get_dev_size(fd, devname, &dsize))
return 1;
!= sizeof(struct bitmap_super_s))
goto no_bitmap;
- uuid_from_super0(uuid, super);
+ uuid_from_super0(st, uuid, super);
bsb = (struct bitmap_super_s *)(super+1);
if (__le32_to_cpu(bsb->magic) != BITMAP_MAGIC ||
memcmp(bsb->uuid, uuid, 16) != 0)
memset(bms, 0, sizeof(*bms));
bms->magic = __cpu_to_le32(BITMAP_MAGIC);
bms->version = __cpu_to_le32(major);
- uuid_from_super0((int*)bms->uuid, sb);
+ uuid_from_super0(st, (int*)bms->uuid, sb);
bms->chunksize = __cpu_to_le32(chunk);
bms->daemon_sleep = __cpu_to_le32(delay);
bms->sync_size = __cpu_to_le64(size);
unsigned long long dsize;
unsigned long long offset;
mdp_super_t *sb = sbv;
-
+
int rv = 0;
int towrite, n;
memset(buf, 0xff, sizeof(buf));
while (towrite > 0) {
n = towrite;
- if (n > sizeof(buf))
+ if (n > sizeof(buf))
n = sizeof(buf);
n = write(fd, buf, n);
if (n > 0)
return rv;
}
+static void free_super0(struct supertype *st, void *super)
+{
+ if (super)
+ free(super);
+}
+
struct superswitch super0 = {
#ifndef MDASSEMBLE
.examine_super = examine_super0,
.add_internal_bitmap = add_internal_bitmap0,
.locate_bitmap = locate_bitmap0,
.write_bitmap = write_bitmap0,
+ .free_super = free_super0,
.major = 0,
.swapuuid = 0,
};