From 9fca7d6236e9775d0269b9802f740c08db46f4d7 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 29 May 2006 02:06:32 +0000 Subject: check return status of all write/fwrite functions as required by glibc 2.4 From: Luca Berra 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 --- bitmap.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'bitmap.c') 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; } -- cgit