diff options
author | Neil Brown <neilb@suse.de> | 2005-08-04 04:41:12 +0000 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2005-08-04 04:41:12 +0000 |
commit | f277ce367125882ea809f981172b8d5c0cc4d5c7 (patch) | |
tree | 9694dfe2d09a972eb38c0d33d8ba6a5153ccb2f6 /util.c | |
parent | 11018a4592680d0d9312c21bf7689bc8db55a609 (diff) | |
download | mdadm-f277ce367125882ea809f981172b8d5c0cc4d5c7.tar.gz mdadm-f277ce367125882ea809f981172b8d5c0cc4d5c7.tar.xz mdadm-f277ce367125882ea809f981172b8d5c0cc4d5c7.zip |
Assorted Fixes for multiple bugs.
Assemble would crash, or just not work.
A few other problem found by a new test-suite.
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 35 |
1 files changed, 27 insertions, 8 deletions
@@ -140,14 +140,32 @@ int enough(int level, int raid_disks, int avail_disks) } } -int same_uuid(int a[4], int b[4]) +int same_uuid(int a[4], int b[4], int swapuuid) { - if (a[0]==b[0] && - a[1]==b[1] && - a[2]==b[2] && - a[3]==b[3]) - return 1; - return 0; + if (swapuuid) { + /* parse uuids are hostendian. + * uuid's from some superblocks are big-ending + * if there is a difference, we need to swap.. + */ + unsigned char *ac = (unsigned char *)a; + unsigned char *bc = (unsigned char *)b; + int i; + for (i=0; i<16; i+= 4) { + if (ac[i+0] != bc[i+3] || + ac[i+1] != bc[i+2] || + ac[i+2] != bc[i+1] || + ac[i+3] != bc[i+0]) + return 0; + } + return 1; + } else { + if (a[0]==b[0] && + a[1]==b[1] && + a[2]==b[2] && + a[3]==b[3]) + return 1; + return 0; + } } int check_ext2(int fd, char *name) @@ -585,6 +603,7 @@ struct supertype *guess_super(int fd) for (i=0 ; superlist[i]; i++) { int rv; ss = superlist[i]; + st->ss = NULL; rv = ss->load_super(st, fd, &sbp, NULL); if (rv == 0) { struct mdinfo info; @@ -594,12 +613,12 @@ struct supertype *guess_super(int fd) bestsuper = i; besttime = info.array.ctime; } - st->ss = NULL; free(sbp); } } if (bestsuper != -1) { int rv; + st->ss = NULL; rv = superlist[bestsuper]->load_super(st, fd, &sbp, NULL); if (rv == 0) { free(sbp); |