Lines Matching refs:bitmap

50  * new-style interfaces will support either type of bitmap, although
52 * new-style interface and the new-style bitmap are used.
54 * For example, the new bitmap interfaces will check the structure
55 * magic numbers and so will be able to detect old-stype bitmap. If
56 * they see an old-style bitmap, they will pass it to the gen_bitmap.c
66 * loop detections in pass 3, the bitmap will *always* be sparse, so
70 static void warn_bitmap(ext2fs_generic_bitmap bitmap,
74 if (bitmap->description)
75 com_err(0, bitmap->base_error_code+code,
76 "#%llu for %s", arg, bitmap->description);
78 com_err(0, bitmap->base_error_code + code, "#%llu", arg);
95 ext2fs_generic_bitmap bitmap;
122 &bitmap);
127 if (gettimeofday(&bitmap->stats.created,
130 ext2fs_free_mem(&bitmap);
133 bitmap->stats.type = type;
137 bitmap->magic = magic;
138 bitmap->fs = fs;
139 bitmap->start = start;
140 bitmap->end = end;
141 bitmap->real_end = real_end;
142 bitmap->bitmap_ops = ops;
143 bitmap->cluster_bits = 0;
146 bitmap->base_error_code = EXT2_ET_BAD_INODE_MARK;
149 bitmap->base_error_code = EXT2_ET_BAD_BLOCK_MARK;
150 bitmap->cluster_bits = fs->cluster_ratio_bits;
153 bitmap->base_error_code = EXT2_ET_BAD_GENERIC_MARK;
156 retval = ext2fs_get_mem(strlen(descr)+1, &bitmap->description);
158 ext2fs_free_mem(&bitmap);
161 strcpy(bitmap->description, descr);
163 bitmap->description = 0;
165 retval = bitmap->bitmap_ops->new_bmap(fs, bitmap);
167 ext2fs_free_mem(&bitmap->description);
168 ext2fs_free_mem(&bitmap);
172 *ret = bitmap;
177 static void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap bitmap)
179 struct ext2_bmap_statistics *stats = &bitmap->stats;
213 fprintf(stderr, "\n[+] %s bitmap (type %d)\n", bitmap->description,
218 bitmap->real_end - bitmap->start);
289 /* Allocate a new bitmap struct */
361 errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap bitmap,
365 if (!bitmap)
368 if (EXT2FS_IS_32_BITMAP(bitmap)) {
372 retval = ext2fs_fudge_generic_bitmap_end(bitmap, bitmap->magic,
379 if (!EXT2FS_IS_64_BITMAP(bitmap))
382 if (end > bitmap->real_end)
385 *oend = bitmap->end;
386 bitmap->end = end;
390 __u64 ext2fs_get_generic_bmap_start(ext2fs_generic_bitmap bitmap)
392 if (!bitmap)
395 if (EXT2FS_IS_32_BITMAP(bitmap))
396 return ext2fs_get_generic_bitmap_start(bitmap);
398 if (!EXT2FS_IS_64_BITMAP(bitmap))
401 return bitmap->start;
404 __u64 ext2fs_get_generic_bmap_end(ext2fs_generic_bitmap bitmap)
406 if (!bitmap)
409 if (EXT2FS_IS_32_BITMAP(bitmap))
410 return ext2fs_get_generic_bitmap_end(bitmap);
412 if (!EXT2FS_IS_64_BITMAP(bitmap))
415 return bitmap->end;
418 void ext2fs_clear_generic_bmap(ext2fs_generic_bitmap bitmap)
420 if (EXT2FS_IS_32_BITMAP(bitmap))
421 ext2fs_clear_generic_bitmap(bitmap);
423 bitmap->bitmap_ops->clear_bmap (bitmap);
426 int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap,
429 if (!bitmap)
432 if (EXT2FS_IS_32_BITMAP(bitmap)) {
434 ext2fs_warn_bitmap2(bitmap,
438 return ext2fs_mark_generic_bitmap(bitmap, arg);
441 if (!EXT2FS_IS_64_BITMAP(bitmap))
444 arg >>= bitmap->cluster_bits;
447 if (arg == bitmap->stats.last_marked + 1)
448 bitmap->stats.mark_seq++;
449 if (arg < bitmap->stats.last_marked)
450 bitmap->stats.mark_back++;
451 bitmap->stats.last_marked = arg;
452 bitmap->stats.mark_count++;
455 if ((arg < bitmap->start) || (arg > bitmap->end)) {
456 warn_bitmap(bitmap, EXT2FS_MARK_ERROR, arg);
460 return bitmap->bitmap_ops->mark_bmap(bitmap, arg);
463 int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap,
466 if (!bitmap)
469 if (EXT2FS_IS_32_BITMAP(bitmap)) {
471 ext2fs_warn_bitmap2(bitmap, EXT2FS_UNMARK_ERROR,
475 return ext2fs_unmark_generic_bitmap(bitmap, arg);
478 if (!EXT2FS_IS_64_BITMAP(bitmap))
481 arg >>= bitmap->cluster_bits;
483 INC_STAT(bitmap, unmark_count);
485 if ((arg < bitmap->start) || (arg > bitmap->end)) {
486 warn_bitmap(bitmap, EXT2FS_UNMARK_ERROR, arg);
490 return bitmap->bitmap_ops->unmark_bmap(bitmap, arg);
493 int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap,
496 if (!bitmap)
499 if (EXT2FS_IS_32_BITMAP(bitmap)) {
501 ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR,
505 return ext2fs_test_generic_bitmap(bitmap, arg);
508 if (!EXT2FS_IS_64_BITMAP(bitmap))
511 arg >>= bitmap->cluster_bits;
514 bitmap->stats.test_count++;
515 if (arg == bitmap->stats.last_tested + 1)
516 bitmap->stats.test_seq++;
517 if (arg < bitmap->stats.last_tested)
518 bitmap->stats.test_back++;
519 bitmap->stats.last_tested = arg;
522 if ((arg < bitmap->start) || (arg > bitmap->end)) {
523 warn_bitmap(bitmap, EXT2FS_TEST_ERROR, arg);
527 return bitmap->bitmap_ops->test_bmap(bitmap, arg);
743 void ext2fs_warn_bitmap32(ext2fs_generic_bitmap bitmap, const char *func)
746 if (bitmap && bitmap->description)
748 "called %s with 64-bit bitmap for %s", func,
749 bitmap->description);
752 "called %s with 64-bit bitmap", func);
757 ext2fs_block_bitmap *bitmap)
764 bmap = *bitmap;
769 retval = ext2fs_allocate_block_bitmap(fs, "converted cluster bitmap",
795 *bitmap = cmap;
799 errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap,
804 if (!bitmap)
807 if (EXT2FS_IS_64_BITMAP(bitmap) && bitmap->bitmap_ops->find_first_zero)
808 return bitmap->bitmap_ops->find_first_zero(bitmap, start,
811 if (EXT2FS_IS_32_BITMAP(bitmap)) {
817 ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, start);
821 retval = ext2fs_find_first_zero_generic_bitmap(bitmap, start,
828 if (!EXT2FS_IS_64_BITMAP(bitmap))
831 start >>= bitmap->cluster_bits;
832 end >>= bitmap->cluster_bits;
834 if (start < bitmap->start || end > bitmap->end || start > end) {
835 warn_bitmap(bitmap, EXT2FS_TEST_ERROR, start);
840 b = bitmap->bitmap_ops->test_bmap(bitmap, start);
842 *out = start << bitmap->cluster_bits;