1 /* vi: set sw=4 ts=4: */
3 * cmp_bitmaps.c --- routines to compare inode and block bitmaps.
5 * Copyright (C) 1995 Theodore Ts'o.
8 * This file may be redistributed under the terms of the GNU Public
24 #include <sys/types.h>
30 errcode_t ext2fs_compare_block_bitmap(ext2fs_block_bitmap bm1,
31 ext2fs_block_bitmap bm2)
35 EXT2_CHECK_MAGIC(bm1, EXT2_ET_MAGIC_BLOCK_BITMAP);
36 EXT2_CHECK_MAGIC(bm2, EXT2_ET_MAGIC_BLOCK_BITMAP);
38 if ((bm1->start != bm2->start) ||
39 (bm1->end != bm2->end) ||
40 (memcmp(bm1->bitmap, bm2->bitmap,
41 (size_t) (bm1->end - bm1->start)/8)))
42 return EXT2_ET_NEQ_BLOCK_BITMAP;
44 for (i = bm1->end - ((bm1->end - bm1->start) % 8); i <= bm1->end; i++)
45 if (ext2fs_fast_test_block_bitmap(bm1, i) !=
46 ext2fs_fast_test_block_bitmap(bm2, i))
47 return EXT2_ET_NEQ_BLOCK_BITMAP;
52 errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1,
53 ext2fs_inode_bitmap bm2)
57 EXT2_CHECK_MAGIC(bm1, EXT2_ET_MAGIC_INODE_BITMAP);
58 EXT2_CHECK_MAGIC(bm2, EXT2_ET_MAGIC_INODE_BITMAP);
60 if ((bm1->start != bm2->start) ||
61 (bm1->end != bm2->end) ||
62 (memcmp(bm1->bitmap, bm2->bitmap,
63 (size_t) (bm1->end - bm1->start)/8)))
64 return EXT2_ET_NEQ_INODE_BITMAP;
66 for (i = bm1->end - ((bm1->end - bm1->start) % 8); i <= bm1->end; i++)
67 if (ext2fs_fast_test_inode_bitmap(bm1, i) !=
68 ext2fs_fast_test_inode_bitmap(bm2, i))
69 return EXT2_ET_NEQ_INODE_BITMAP;