2 * cmp_bitmaps.c --- routines to compare inode and block bitmaps.
4 * Copyright (C) 1995 Theodore Ts'o.
7 * This file may be redistributed under the terms of the GNU Public
23 #include <sys/types.h>
29 errcode_t ext2fs_compare_block_bitmap(ext2fs_block_bitmap bm1,
30 ext2fs_block_bitmap bm2)
34 EXT2_CHECK_MAGIC(bm1, EXT2_ET_MAGIC_BLOCK_BITMAP);
35 EXT2_CHECK_MAGIC(bm2, EXT2_ET_MAGIC_BLOCK_BITMAP);
37 if ((bm1->start != bm2->start) ||
38 (bm1->end != bm2->end) ||
39 (memcmp(bm1->bitmap, bm2->bitmap,
40 (size_t) (bm1->end - bm1->start)/8)))
41 return EXT2_ET_NEQ_BLOCK_BITMAP;
43 for (i = bm1->end - ((bm1->end - bm1->start) % 8); i <= bm1->end; i++)
44 if (ext2fs_fast_test_block_bitmap(bm1, i) !=
45 ext2fs_fast_test_block_bitmap(bm2, i))
46 return EXT2_ET_NEQ_BLOCK_BITMAP;
51 errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1,
52 ext2fs_inode_bitmap bm2)
56 EXT2_CHECK_MAGIC(bm1, EXT2_ET_MAGIC_INODE_BITMAP);
57 EXT2_CHECK_MAGIC(bm2, EXT2_ET_MAGIC_INODE_BITMAP);
59 if ((bm1->start != bm2->start) ||
60 (bm1->end != bm2->end) ||
61 (memcmp(bm1->bitmap, bm2->bitmap,
62 (size_t) (bm1->end - bm1->start)/8)))
63 return EXT2_ET_NEQ_INODE_BITMAP;
65 for (i = bm1->end - ((bm1->end - bm1->start) % 8); i <= bm1->end; i++)
66 if (ext2fs_fast_test_inode_bitmap(bm1, i) !=
67 ext2fs_fast_test_inode_bitmap(bm2, i))
68 return EXT2_ET_NEQ_INODE_BITMAP;