diff --git a/Assemble.c b/Assemble.c index 816a88e..cb97f8c 100644 --- a/Assemble.c +++ b/Assemble.c @@ -451,7 +451,9 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, if (strcmp(update, "uuid")==0 && ident->bitmap_fd) - bitmap_update_uuid(ident->bitmap_fd, info.uuid); + if (bitmap_update_uuid(ident->bitmap_fd, info.uuid) != 0) + fprintf(stderr, Name ": Could not update uuid on %s.\n", + devname); } else #endif { diff --git a/Grow.c b/Grow.c index 8c8aa28..61347b7 100644 --- a/Grow.c +++ b/Grow.c @@ -801,7 +801,10 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file, memset(&bsb, 0, sizeof(bsb)); for (i=odisks; i 0) - fwrite(buf, 1, n, mp); + n=fwrite(buf, 1, n, mp); /* yes, i don't care about the result */ fclose(mdstat); } fclose(mp); 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; } diff --git a/mdadm.h b/mdadm.h index 46d4ec0..848c6f1 100644 --- a/mdadm.h +++ b/mdadm.h @@ -381,7 +381,7 @@ extern int CreateBitmap(char *filename, int force, char uuid[16], unsigned long long array_size, int major); extern int ExamineBitmap(char *filename, int brief, struct supertype *st); -extern void bitmap_update_uuid(int fd, int *uuid); +extern int bitmap_update_uuid(int fd, int *uuid); extern int md_get_version(int fd); extern int get_linux_version(void); diff --git a/super0.c b/super0.c index 4d02300..f14f076 100644 --- a/super0.c +++ b/super0.c @@ -625,7 +625,8 @@ static int store_super0(struct supertype *st, int fd, void *sbv) if (super->state & (1<magic) == BITMAP_MAGIC) - write(fd, bm, sizeof(*bm)); + if (write(fd, bm, sizeof(*bm)) != sizeof(*bm)) + return 5; } fsync(fd); diff --git a/super1.c b/super1.c index 8f648f6..28332cd 100644 --- a/super1.c +++ b/super1.c @@ -715,7 +715,8 @@ static int store_super1(struct supertype *st, int fd, void *sbv) (((char*)sb)+1024); if (__le32_to_cpu(bm->magic) == BITMAP_MAGIC) { locate_bitmap1(st, fd, sbv); - write(fd, bm, sizeof(*bm)); + if (write(fd, bm, sizeof(*bm)) != sizeof(*bm)) + return 5; } } fsync(fd);