summaryrefslogtreecommitdiff
path: root/super1.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2006-05-19 06:56:06 +0000
committerNeil Brown <neilb@suse.de>2006-05-19 06:56:06 +0000
commit05697ec1e26eadc2f814d9f84f8c783fff5b98b5 (patch)
treefed33270814c73af6757e0959f46e3ffafba7905 /super1.c
parent997aed5deeabc74eefcf37a0f042ac8707dfe227 (diff)
Make homehost information appear in superblock.
When an array is created, if the homehost is know, the superblock gets it, either in the uuid, (via sha1) or in the name field. Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'super1.c')
-rw-r--r--super1.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/super1.c b/super1.c
index cc0a5e30..a29795a6 100644
--- a/super1.c
+++ b/super1.c
@@ -498,16 +498,20 @@ static __u64 event_super1(void *sbv)
return __le64_to_cpu(sb->events);
}
-static int init_super1(struct supertype *st, void **sbp, mdu_array_info_t *info, unsigned long long size, char *name)
+static int init_super1(struct supertype *st, void **sbp, mdu_array_info_t *info,
+ unsigned long long size, char *name, char *homehost)
{
struct mdp_superblock_1 *sb = malloc(1024 + sizeof(bitmap_super_t));
int spares;
int rfd;
+ char defname[10];
memset(sb, 0, 1024);
- if (info->major_version == -1)
+ if (info->major_version == -1) {
/* zeroing superblock */
+ *sbp = sb;
return 0;
+ }
spares = info->working_disks - info->active_disks;
if (info->raid_disks + spares > 384) {
@@ -516,7 +520,6 @@ static int init_super1(struct supertype *st, void **sbp, mdu_array_info_t *info,
return 0;
}
-
sb->magic = __cpu_to_le32(MD_SB_MAGIC);
sb->major_version = __cpu_to_le32(1);
sb->feature_map = 0;
@@ -531,8 +534,19 @@ static int init_super1(struct supertype *st, void **sbp, mdu_array_info_t *info,
}
if (rfd >= 0) close(rfd);
+ if (name == NULL || *name == 0) {
+ sprintf(defname, "%d", info->md_minor);
+ name = defname;
+ }
memset(sb->set_name, 0, 32);
- strcpy(sb->set_name, name);
+ if (homehost &&
+ strchr(name, ':')== NULL &&
+ strlen(homehost)+1+strlen(name) < 32) {
+ strcpy(sb->set_name, homehost);
+ strcat(sb->set_name, ":");
+ strcat(sb->set_name, name);
+ } else
+ strcpy(sb->set_name, name);
sb->ctime = __cpu_to_le64((unsigned long long)time(0));
sb->level = __cpu_to_le32(info->level);