]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - bitmap.c
check return status of all write/fwrite functions as required by glibc 2.4
[thirdparty/mdadm.git] / bitmap.c
index 8210278f356910fda95c9ac741475d8afcd80c17..59410d543e67c41285391a568e679711d88a5a22 100644 (file)
--- a/bitmap.c
+++ b/bitmap.c
@@ -399,16 +399,22 @@ out:
        return rv;
 }
 
-void bitmap_update_uuid(int fd, int *uuid)
+int bitmap_update_uuid(int fd, int *uuid)
 {
        struct bitmap_super_s bm;
-       lseek(fd, 0, 0);
+       if (lseek(fd, 0, 0) != 0)
+               return 1;
        if (read(fd, &bm, sizeof(bm)) != sizeof(bm))
-               return;
+               return 1;
        if (bm.magic != __cpu_to_le32(BITMAP_MAGIC))
-               return;
+               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);
-       write(fd, &bm, sizeof(bm));
-       lseek(fd, 0, 0);
+       return 0;
 }