if (vers < 9003) {
major = BITMAP_MAJOR_HOSTENDIAN;
-#ifdef __BIG_ENDIAN
- fprintf(stderr, Name ": Warning - bitmaps created on this kernel are not portable\n"
- " between different architectured. Consider upgrading the Linux kernel.\n");
-#endif
+ fprintf(stderr, Name ": Warning - bitmaps created on this kernel"
+ " are not portable\n"
+ " between different architectures. Consider upgrading"
+ " the Linux kernel.\n");
}
if (ioctl(fd, GET_BITMAP_FILE, &bmf) != 0) {
}
array.state |= (1<<MD_SB_BITMAP_PRESENT);
if (ioctl(fd, SET_ARRAY_INFO, &array)!= 0) {
+ if (errno == EBUSY)
+ fprintf(stderr, Name
+ ": Cannot add bitmap while array is"
+ " resyncing or reshaping etc.\n");
fprintf(stderr, Name ": failed to set internal bitmap.\n");
return 1;
}
return 1;
}
if (ioctl(fd, SET_BITMAP_FILE, bitmap_fd) < 0) {
+ int err = errno;
+ if (errno == EBUSY)
+ fprintf(stderr, Name
+ ": Cannot add bitmap while array is"
+ " resyncing or reshaping etc.\n");
fprintf(stderr, Name ": Cannot set bitmap file for %s: %s\n",
- devname, strerror(errno));
+ devname, strerror(err));
return 1;
}
}
} else {
/* need to check backup file is large enough */
char buf[512];
+ struct stat stb;
+ unsigned int dev;
fdlist[d] = open(backup_file, O_RDWR|O_CREAT|O_EXCL,
S_IRUSR | S_IWUSR);
offsets[d] = 8 * 512;
rv = 1;
break;
}
+ /* Guard against backup file being on array device.
+ * If array is partitioned or if LVM etc is in the
+ * way this will not notice, but it is better than
+ * nothing.
+ */
+ fstat(fdlist[d], &stb);
+ dev = stb.st_dev;
+ fstat(fd, &stb);
+ if (stb.st_rdev == dev) {
+ fprintf(stderr, Name ": backup file must NOT be"
+ " on the array being reshaped.\n");
+ rv = 1;
+ close(fdlist[d]);
+ break;
+ }
+
memset(buf, 0, 512);
for (i=0; i < (signed)blocks + 8 ; i++) {
if (write(fdlist[d], buf, 512) != 512) {