errcode_t ext2fs_compare_generic_bmap(errcode_t neq, ext2fs_generic_bitmap bm1, ext2fs_generic_bitmap bm2) { blk64_t i; if (!bm1 || !bm2) return EINVAL; if (bm1->magic != bm2->magic) return EINVAL; /* Now we know both bitmaps have the same magic */ if (EXT2FS_IS_32_BITMAP(bm1)) return ext2fs_compare_generic_bitmap(bm1->magic, neq, bm1, bm2); if (!EXT2FS_IS_64_BITMAP(bm1)) return EINVAL; if ((bm1->start != bm2->start) || (bm1->end != bm2->end)) return neq; for (i = bm1->end - ((bm1->end - bm1->start) % 8); i <= bm1->end; i++) if (ext2fs_test_generic_bmap(bm1, i) != ext2fs_test_generic_bmap(bm2, i)) return neq; return 0; }
int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bmap, blk64_t block, unsigned int num) { if (!bmap) return EINVAL; if (num == 1) return !ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bmap, block); if (EXT2FS_IS_32_BITMAP(bmap)) { if ((block+num) & ~0xffffffffULL) { ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bmap, EXT2FS_UNMARK_ERROR, 0xffffffff); return EINVAL; } return ext2fs_test_block_bitmap_range( (ext2fs_generic_bitmap) bmap, block, num); } if (!EXT2FS_IS_64_BITMAP(bmap)) return EINVAL; return bmap->bitmap_ops->test_clear_bmap_extent(bmap, block, num); }
int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bmap, blk64_t block, unsigned int num) { __u64 end = block + num; if (!bmap) return EINVAL; if (num == 1) return !ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bmap, block); if (EXT2FS_IS_32_BITMAP(bmap)) { if ((block+num-1) & ~0xffffffffULL) { ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bmap, EXT2FS_UNMARK_ERROR, 0xffffffff); return EINVAL; } return ext2fs_test_block_bitmap_range( (ext2fs_generic_bitmap) bmap, block, num); } if (!EXT2FS_IS_64_BITMAP(bmap)) return EINVAL; INC_STAT(bmap, test_ext_count); /* convert to clusters if necessary */ block >>= bmap->cluster_bits; end += (1 << bmap->cluster_bits) - 1; end >>= bmap->cluster_bits; num = end - block; if ((block < bmap->start) || (block+num-1 > bmap->end)) { ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_TEST, block, bmap->description); //change return value to none to 0, build error fix return 0; } return bmap->bitmap_ops->test_clear_bmap_extent(bmap, block, num); }
int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap, blk_t bitno) { if (!EXT2FS_IS_32_BITMAP(bitmap)) { if (EXT2FS_IS_64_BITMAP(bitmap)) { ext2fs_warn_bitmap32(bitmap, __func__); return ext2fs_test_generic_bmap(bitmap, bitno); } #ifndef OMIT_COM_ERR com_err(0, EXT2_ET_MAGIC_GENERIC_BITMAP, "test_bitmap(%lu)", (unsigned long) bitno); #endif return 0; } if ((bitno < bitmap->start) || (bitno > bitmap->end)) { ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, bitno); return 0; } return ext2fs_test_bit(bitno - bitmap->start, bitmap->bitmap); }