summaryrefslogtreecommitdiffstats
path: root/super0.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 /super0.c
parent997aed5deeabc74eefcf37a0f042ac8707dfe227 (diff)
downloadmdadm-05697ec1e26eadc2f814d9f84f8c783fff5b98b5.tar.gz
mdadm-05697ec1e26eadc2f814d9f84f8c783fff5b98b5.tar.xz
mdadm-05697ec1e26eadc2f814d9f84f8c783fff5b98b5.zip
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 'super0.c')
-rw-r--r--super0.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/super0.c b/super0.c
index 0bf38ed..7fe2336 100644
--- a/super0.c
+++ b/super0.c
@@ -28,7 +28,7 @@
*/
#include "mdadm.h"
-
+#include <openssl/sha.h> /* for SHA1 */
/*
* All handling for the 0.90.0 version superblock is in
* this file.
@@ -449,9 +449,17 @@ static __u64 event_super0(void *sbv)
return md_event(sb);
}
+/*
+ * For verion-0 superblock, the homehost is 'stored' in the
+ * uuid. 8 bytes for a hash of the host leaving 8 bytes
+ * of random material.
+ * We use the first 8 bytes (64bits) of the sha1 of the
+ * host name
+ */
-static int init_super0(struct supertype *st, void **sbp, mdu_array_info_t *info, unsigned long long size, char *ignored_name)
+static int init_super0(struct supertype *st, void **sbp, mdu_array_info_t *info,
+ unsigned long long size, char *ignored_name, char *homehost)
{
mdp_super_t *sb = malloc(MD_SB_BYTES + sizeof(bitmap_super_t));
int spares;
@@ -460,6 +468,7 @@ static int init_super0(struct supertype *st, void **sbp, mdu_array_info_t *info,
if (info->major_version == -1) {
/* zeroing the superblock */
+ *sbp = sb;
return 0;
}
@@ -494,6 +503,12 @@ static int init_super0(struct supertype *st, void **sbp, mdu_array_info_t *info,
}
if (rfd >= 0)
close(rfd);
+ if (homehost) {
+ unsigned char *hash = SHA1((unsigned char*)homehost,
+ strlen(homehost),
+ NULL);
+ memcpy(&sb->set_uuid2, hash, 8);
+ }
sb->utime = sb->ctime;
sb->state = info->state;