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
{
memset(&bsb, 0, sizeof(bsb));
for (i=odisks; i<d ; i++) {
lseek64(fdlist[i], (offsets[i]+last_block)<<9, 0);
- write(fdlist[i], &bsb, sizeof(bsb));
+ if (write(fdlist[i], &bsb, sizeof(bsb)) < 0) {
+ fprintf(stderr, Name ": %s: failed to invalidate metadata for raid disk %d\n",
+ devname, i);
+ }
}
/* unsuspend. */
int n;
fprintf(mp, "\nP.S. The /proc/mdstat file current contains the following:\n\n");
while ( (n=fread(buf, 1, sizeof(buf), mdstat)) > 0)
- fwrite(buf, 1, n, mp);
+ n=fwrite(buf, 1, n, mp); /* yes, i don't care about the result */
fclose(mdstat);
}
fclose(mp);
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;
}
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);
if (super->state & (1<<MD_SB_BITMAP_PRESENT)) {
struct bitmap_super_s * bm = (struct bitmap_super_s*)(super+1);
if (__le32_to_cpu(bm->magic) == BITMAP_MAGIC)
- write(fd, bm, sizeof(*bm));
+ if (write(fd, bm, sizeof(*bm)) != sizeof(*bm))
+ return 5;
}
fsync(fd);
(((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);