X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=bitmap.c;h=59410d543e67c41285391a568e679711d88a5a22;hb=067db4dfcd6830e076a759ec2cdcbf2c6566be6e;hp=75492f759fe0c2ad2c8ee7464b556ed2163dc8ae;hpb=1bfdbe01ff300ebbf92d68c15722d2ba861aac3b;p=thirdparty%2Fmdadm.git diff --git a/bitmap.c b/bitmap.c index 75492f75..59410d54 100644 --- a/bitmap.c +++ b/bitmap.c @@ -398,3 +398,23 @@ out: unlink(filename); /* possibly corrupted, better get rid of it */ return rv; } + +int bitmap_update_uuid(int fd, int *uuid) +{ + struct bitmap_super_s bm; + if (lseek(fd, 0, 0) != 0) + return 1; + if (read(fd, &bm, sizeof(bm)) != sizeof(bm)) + return 1; + if (bm.magic != __cpu_to_le32(BITMAP_MAGIC)) + return 1; + memcpy(bm.uuid, uuid, 16); + if (lseek(fd, 0, 0) != 0) + return 2; + if (write(fd, &bm, sizeof(bm)) != sizeof(bm)) { + lseek(fd, 0, 0); + return 2; + } + lseek(fd, 0, 0); + return 0; +}