summaryrefslogtreecommitdiffstats
path: root/super0.c
diff options
context:
space:
mode:
authorJes Sorensen <Jes.Sorensen@redhat.com>2016-08-15 21:48:56 +0200
committerJes Sorensen <Jes.Sorensen@redhat.com>2016-08-15 21:48:56 +0200
commit055b766b1c3dee54425dcd46974892cb3f13dbf7 (patch)
treee427f22d99f9ecdcb2da50d554618105604a04f5 /super0.c
parentIntroduce random_uuid() helper function (diff)
downloadmdadm-055b766b1c3dee54425dcd46974892cb3f13dbf7.tar.xz
mdadm-055b766b1c3dee54425dcd46974892cb3f13dbf7.zip
super0: Use random_uuid() in init_super0()
This shaves another 80 bytes off the mdadm binary. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Diffstat (limited to '')
-rw-r--r--super0.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/super0.c b/super0.c
index 467a3737..333860c4 100644
--- a/super0.c
+++ b/super0.c
@@ -752,16 +752,12 @@ static int init_super0(struct supertype *st, mdu_array_info_t *info,
sb->set_uuid2 = uuid[2];
sb->set_uuid3 = uuid[3];
} else {
- int rfd = open("/dev/urandom", O_RDONLY);
- if (rfd < 0 || read(rfd, &sb->set_uuid0, 4) != 4)
- sb->set_uuid0 = random();
- if (rfd < 0 || read(rfd, &sb->set_uuid1, 12) != 12) {
- sb->set_uuid1 = random();
- sb->set_uuid2 = random();
- sb->set_uuid3 = random();
- }
- if (rfd >= 0)
- close(rfd);
+ __u32 r[4];
+ random_uuid((__u8 *)r);
+ sb->set_uuid0 = r[0];
+ sb->set_uuid1 = r[1];
+ sb->set_uuid2 = r[2];
+ sb->set_uuid3 = r[3];
}
if (homehost && !uuid) {
char buf[20];