#define MD_FEATURE_ALL (1|2|4)
#ifndef offsetof
-#define offsetof(t,f) ((int)&(((t*)0)->f))
+#define offsetof(t,f) ((size_t)&(((t*)0)->f))
#endif
static unsigned int calc_sb_1_csum(struct mdp_superblock_1 * sb)
{
disk_csum = sb->sb_csum;
sb->sb_csum = 0;
newcsum = 0;
- for (i=0; size>=4; size -= 4 )
- newcsum += __le32_to_cpu(*isuper++);
+ for (i=0; size>=4; size -= 4 ) {
+ newcsum += __le32_to_cpu(*isuper);
+ isuper++;
+ }
if (size == 2)
newcsum += __le16_to_cpu(*(unsigned short*) isuper);
}
#ifndef MDASSEMBLE
-static void examine_super1(void *sbv)
+static void examine_super1(void *sbv, char *homehost)
{
struct mdp_superblock_1 *sb = sbv;
time_t atime;
int faulty;
int i;
char *c;
+ int l = homehost ? strlen(homehost) : 0;
printf(" Magic : %08x\n", __le32_to_cpu(sb->magic));
printf(" Version : %02d\n", 1);
printf("%02x", sb->set_uuid[i]);
}
printf("\n");
- printf(" Name : %.32s\n", sb->set_name);
-
+ printf(" Name : %.32s", sb->set_name);
+ if (l > 0 && l < 32 &&
+ sb->set_name[l] == ':' &&
+ strncmp(sb->set_name, homehost, l) == 0)
+ printf(" (local to host %s)", homehost);
+ printf("\n");
atime = __le64_to_cpu(sb->ctime) & 0xFFFFFFFFFFULL;
printf(" Creation Time : %.24s\n", ctime(&atime));
c=map_num(pers, __le32_to_cpu(sb->level));
{
struct mdp_superblock_1 *sb = sbv;
int i;
-
+ char *nm;
char *c=map_num(pers, __le32_to_cpu(sb->level));
- printf("ARRAY /dev/?? level=%s metadata=1 num-devices=%d UUID=",
+ nm = strchr(sb->set_name, ':');
+ if (nm)
+ nm++;
+ else if (sb->set_name[0])
+ nm = sb->set_name;
+ else
+ nm = "??";
+
+ printf("ARRAY /dev/md/%s level=%s metadata=1 num-devices=%d UUID=",
+ nm,
c?c:"-unknown-", sb->raid_disks);
for (i=0; i<16; i++) {
printf("%02x", sb->set_uuid[i]);
#endif
+static int match_home1(void *sbv, char *homehost)
+{
+ struct mdp_superblock_1 *sb = sbv;
+ int l = homehost ? strlen(homehost) : 0;
+
+ return (l > 0 && l < 32 &&
+ sb->set_name[l] == ':' &&
+ strncmp(sb->set_name, homehost, l) == 0);
+}
+
static void uuid_from_super1(int uuid[4], void * sbv)
{
struct mdp_superblock_1 *super = sbv;
info->array.working_disks = working;
}
-static int update_super1(struct mdinfo *info, void *sbv, char *update, char *devname, int verbose)
+static int update_super1(struct mdinfo *info, void *sbv, char *update,
+ char *devname, int verbose,
+ int uuid_set, char *homehost)
{
/* NOTE: for 'assemble' and 'force' we need to return non-zero if any change was made.
* For others, the return value is ignored.
memcpy(bm->uuid, info->uuid, 16);
}
}
+ if (strcmp(update, "homehost") == 0 &&
+ homehost) {
+ char *c;
+ update = "name";
+ c = strchr(sb->set_name, ':');
+ if (c)
+ strncpy(info->name, c+1, 31 - (c-sb->set_name));
+ else
+ strncpy(info->name, sb->set_name, 32);
+ info->name[33] = 0;
+ }
+ 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));
+ if (homehost &&
+ strchr(info->name, ':') == NULL &&
+ strlen(homehost)+1+strlen(info->name) < 32) {
+ strcpy(sb->set_name, homehost);
+ strcat(sb->set_name, ":");
+ strcat(sb->set_name, info->name);
+ } else
+ strcpy(sb->set_name, info->name);
+ }
if (strcmp(update, "_reshape_progress")==0)
sb->reshape_position = __cpu_to_le64(info->reshape_progress);
if (sb->feature_map & __cpu_to_le32(MD_FEATURE_BITMAP_OFFSET)) {
struct bitmap_super_s *bm = (struct bitmap_super_s*)
- ((char*)sb)+1024;
+ (((char*)sb)+1024);
if (__le32_to_cpu(bm->magic) == BITMAP_MAGIC) {
locate_bitmap1(st, fd, sbv);
- write(fd, bm, sizeof(*bm));
+ if (write(fd, bm, sizeof(*bm)) != sizeof(*bm))
+ return 5;
}
}
fsync(fd);
.detail_super = detail_super1,
.brief_detail_super = brief_detail_super1,
#endif
+ .match_home = match_home1,
.uuid_from_super = uuid_from_super1,
.getinfo_super = getinfo_super1,
.update_super = update_super1,