summaryrefslogtreecommitdiffstats
path: root/bitmap.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2006-05-29 02:06:32 +0000
committerNeil Brown <neilb@suse.de>2006-05-29 02:06:32 +0000
commit9fca7d6236e9775d0269b9802f740c08db46f4d7 (patch)
treeaef0c99d844a3eacf037294e6722079c01c44ae9 /bitmap.c
parent280a927d3d8da258a70df13df4f780d823fc1da2 (diff)
downloadmdadm-9fca7d6236e9775d0269b9802f740c08db46f4d7.tar.gz
mdadm-9fca7d6236e9775d0269b9802f740c08db46f4d7.tar.xz
mdadm-9fca7d6236e9775d0269b9802f740c08db46f4d7.zip
check return status of all write/fwrite functions as required by glibc 2.4
From: Luca Berra <bluca@vodka.it> glibc 2.4 is pedantic on ignoring return values from fprintf, fwrite and write, so now we check the rval and actually do something with it. in the Grow.c case i only print a warning, since i don't think we can do anything in case we fail invalidating those superblocks (is should never happen, but then...) Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'bitmap.c')
-rw-r--r--bitmap.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/bitmap.c b/bitmap.c
index 8210278..59410d5 100644
--- 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;
}