Home | History | Annotate | Download | only in ext2fs

Lines Matching full:bitmap

51  * new-style interfaces will support either type of bitmap, although
53 * new-style interface and the new-style bitmap are used.
55 * For example, the new bitmap interfaces will check the structure
56 * magic numbers and so will be able to detect old-stype bitmap. If
57 * they see an old-style bitmap, they will pass it to the gen_bitmap.c
67 * loop detections in pass 3, the bitmap will *always* be sparse, so
71 static void warn_bitmap(ext2fs_generic_bitmap bitmap,
75 if (bitmap->description)
76 com_err(0, bitmap->base_error_code+code,
77 "#%llu for %s", arg, bitmap->description);
79 com_err(0, bitmap->base_error_code + code, "#%llu", arg);
96 ext2fs_generic_bitmap bitmap;
123 &bitmap);
128 if (gettimeofday(&bitmap->stats.created,
131 ext2fs_free_mem(&bitmap);
134 bitmap->stats.type = type;
138 bitmap->magic = magic;
139 bitmap->fs = fs;
140 bitmap->start = start;
141 bitmap->end = end;
142 bitmap->real_end = real_end;
143 bitmap->bitmap_ops = ops;
144 bitmap->cluster_bits = 0;
147 bitmap->base_error_code = EXT2_ET_BAD_INODE_MARK;
150 bitmap->base_error_code = EXT2_ET_BAD_BLOCK_MARK;
151 bitmap->cluster_bits = fs->cluster_ratio_bits;
154 bitmap->base_error_code = EXT2_ET_BAD_GENERIC_MARK;
157 retval = ext2fs_get_mem(strlen(descr)+1, &bitmap->description);
159 ext2fs_free_mem(&bitmap);
162 strcpy(bitmap->description, descr);
164 bitmap->description = 0;
166 retval = bitmap->bitmap_ops->new_bmap(fs, bitmap);
168 ext2fs_free_mem(&bitmap->description);
169 ext2fs_free_mem(&bitmap);
173 *ret = bitmap;
178 static void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap bitmap)
180 struct ext2_bmap_statistics *stats = &bitmap->stats;
214 fprintf(stderr, "\n[+] %s bitmap (type %d)\n", bitmap->description,
219 bitmap->real_end - bitmap->start);
290 /* Allocate a new bitmap struct */
363 errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap bitmap,
367 if (!bitmap)
370 if (EXT2FS_IS_32_BITMAP(bitmap)) {
374 retval = ext2fs_fudge_generic_bitmap_end(bitmap, bitmap->magic,
381 if (!EXT2FS_IS_64_BITMAP(bitmap))
384 if (end > bitmap->real_end)
387 *oend = bitmap->end;
388 bitmap->end = end;
392 __u64 ext2fs_get_generic_bmap_start(ext2fs_generic_bitmap bitmap)
394 if (!bitmap)
397 if (EXT2FS_IS_32_BITMAP(bitmap))
398 return ext2fs_get_generic_bitmap_start(bitmap);
400 if (!EXT2FS_IS_64_BITMAP(bitmap))
403 return bitmap->start;
406 __u64 ext2fs_get_generic_bmap_end(ext2fs_generic_bitmap bitmap)
408 if (!bitmap)
411 if (EXT2FS_IS_32_BITMAP(bitmap))
412 return ext2fs_get_generic_bitmap_end(bitmap);
414 if (!EXT2FS_IS_64_BITMAP(bitmap))
417 return bitmap->end;
420 void ext2fs_clear_generic_bmap(ext2fs_generic_bitmap bitmap)
422 if (EXT2FS_IS_32_BITMAP(bitmap))
423 ext2fs_clear_generic_bitmap(bitmap);
425 bitmap->bitmap_ops->clear_bmap (bitmap);
428 int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap,
431 if (!bitmap)
434 if (EXT2FS_IS_32_BITMAP(bitmap)) {
436 ext2fs_warn_bitmap2(bitmap,
440 return ext2fs_mark_generic_bitmap(bitmap, arg);
443 if (!EXT2FS_IS_64_BITMAP(bitmap))
446 arg >>= bitmap->cluster_bits;
449 if (arg == bitmap->stats.last_marked + 1)
450 bitmap->stats.mark_seq++;
451 if (arg < bitmap->stats.last_marked)
452 bitmap->stats.mark_back++;
453 bitmap->stats.last_marked = arg;
454 bitmap->stats.mark_count++;
457 if ((arg < bitmap->start) || (arg > bitmap->end)) {
458 warn_bitmap(bitmap, EXT2FS_MARK_ERROR, arg);
462 return bitmap->bitmap_ops->mark_bmap(bitmap, arg);
465 int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap,
468 if (!bitmap)
471 if (EXT2FS_IS_32_BITMAP(bitmap)) {
473 ext2fs_warn_bitmap2(bitmap, EXT2FS_UNMARK_ERROR,
477 return ext2fs_unmark_generic_bitmap(bitmap, arg);
480 if (!EXT2FS_IS_64_BITMAP(bitmap))
483 arg >>= bitmap->cluster_bits;
485 INC_STAT(bitmap, unmark_count);
487 if ((arg < bitmap->start) || (arg > bitmap->end)) {
488 warn_bitmap(bitmap, EXT2FS_UNMARK_ERROR, arg);
492 return bitmap->bitmap_ops->unmark_bmap(bitmap, arg);
495 int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap,
498 if (!bitmap)
501 if (EXT2FS_IS_32_BITMAP(bitmap)) {
503 ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR,
507 return ext2fs_test_generic_bitmap(bitmap, arg);
510 if (!EXT2FS_IS_64_BITMAP(bitmap))
513 arg >>= bitmap->cluster_bits;
516 bitmap->stats.test_count++;
517 if (arg == bitmap->stats.last_tested + 1)
518 bitmap->stats.test_seq++;
519 if (arg < bitmap->stats.last_tested)
520 bitmap->stats.test_back++;
521 bitmap->stats.last_tested = arg;
524 if ((arg < bitmap->start) || (arg > bitmap->end)) {
525 warn_bitmap(bitmap, EXT2FS_TEST_ERROR, arg);
529 return bitmap->bitmap_ops->test_bmap(bitmap, arg);
745 void ext2fs_warn_bitmap32(ext2fs_generic_bitmap bitmap, const char *func)
748 if (bitmap && bitmap->description)
750 "called %s with 64-bit bitmap for %s", func,
751 bitmap->description);
754 "called %s with 64-bit bitmap", func);
759 ext2fs_block_bitmap *bitmap)
766 bmap = *bitmap;
771 retval = ext2fs_allocate_block_bitmap(fs, "converted cluster bitmap",
797 *bitmap = cmap;
801 errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap,
807 if (!bitmap)
810 if (EXT2FS_IS_32_BITMAP(bitmap)) {
815 ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, start);
819 retval = ext2fs_find_first_zero_generic_bitmap(bitmap, start,
826 if (!EXT2FS_IS_64_BITMAP(bitmap))
829 cstart = start >> bitmap->cluster_bits;
830 cend = end >> bitmap->cluster_bits;
832 if (cstart < bitmap->start || cend > bitmap->end || start > end) {
833 warn_bitmap(bitmap, EXT2FS_TEST_ERROR, start);
837 if (bitmap->bitmap_ops->find_first_zero) {
838 retval = bitmap->bitmap_ops->find_first_zero(bitmap, cstart,
843 cout <<= bitmap->cluster_bits;
849 if (!bitmap->bitmap_ops->test_bmap(bitmap, cout))
855 errcode_t ext2fs_find_first_set_generic_bmap(ext2fs_generic_bitmap bitmap,
861 if (!bitmap)
864 if (EXT2FS_IS_32_BITMAP(bitmap)) {
869 ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, start);
873 retval = ext2fs_find_first_set_generic_bitmap(bitmap, start,
880 if (!EXT2FS_IS_64_BITMAP(bitmap))
883 cstart = start >> bitmap->cluster_bits;
884 cend = end >> bitmap->cluster_bits;
886 if (cstart < bitmap->start || cend > bitmap->end || start > end) {
887 warn_bitmap(bitmap, EXT2FS_TEST_ERROR, start);
891 if (bitmap->bitmap_ops->find_first_set) {
892 retval = bitmap->bitmap_ops->find_first_set(bitmap, cstart,
897 cout <<= bitmap->cluster_bits;
903 if (bitmap->bitmap_ops->test_bmap(bitmap, cout))