]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super1.c
Fix and test --update=uuid
[thirdparty/mdadm.git] / super1.c
index be1a0e5baf9d4be2494b0f4086e5e2d478ea4aff..14f9c8af6563eab2bc6642eec1a9a96fb8e00907 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -536,11 +536,23 @@ static int update_super1(struct mdinfo *info, void *sbv, char *update,
                sb->resync_offset = 0ULL;
        }
        if (strcmp(update, "uuid") == 0) {
-               memcpy(sb->set_uuid, info->uuid, 16);
+               if (super1.swapuuid) {
+                       unsigned char *ac = (unsigned char *)sb->set_uuid;
+                       unsigned char *bc = (unsigned char *)info->uuid;
+                       int i;
+                       for (i=0; i<16; i+= 4) {
+                               ac[i+0] = bc[i+3];
+                               ac[i+1] = bc[i+2];
+                               ac[i+2] = bc[i+1];
+                               ac[i+3] = bc[i+0];
+                       }
+               } else
+                       memcpy(sb->set_uuid, info->uuid, 16);
+
                if (__le32_to_cpu(sb->feature_map)&MD_FEATURE_BITMAP_OFFSET) {
                        struct bitmap_super_s *bm;
                        bm = (struct bitmap_super_s*)(sbv+1024);
-                       memcpy(bm->uuid, info->uuid, 16);
+                       memcpy(bm->uuid, sb->set_uuid, 16);
                }
        }
        if (strcmp(update, "homehost") == 0 &&