+ if (bitmap_file) {
+ bitmap_fd = open(bitmap_file, O_RDWR);
+ if (bitmap_fd < 0) {
+ int major = BITMAP_MAJOR_HI;
+#if 0
+ if (bitmap_chunk == UnSet) {
+ fprintf(stderr, Name ": %s cannot be openned.",
+ bitmap_file);
+ return 1;
+ }
+#endif
+ 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 architectures. Consider upgrading the Linux kernel.\n");
+#endif
+ }
+ bitmapsize = size>>9; /* FIXME wrong for RAID10 */
+ if (CreateBitmap(bitmap_file, 1, NULL, bitmap_chunk,
+ delay, write_behind, bitmapsize, major)) {
+ return 1;
+ }
+ bitmap_fd = open(bitmap_file, O_RDWR);
+ if (bitmap_fd < 0) {
+ fprintf(stderr, Name ": %s cannot be openned.",
+ bitmap_file);
+ return 1;
+ }
+ }
+ if (bitmap_fd >= 0) {
+ if (ioctl(mdfd, SET_BITMAP_FILE, bitmap_fd) < 0) {
+ fprintf(stderr, Name ": Cannot set bitmap file for %s: %s\n",
+ mddev, strerror(errno));
+ return 1;
+ }
+ }
+ }