Changes for kernel and Busybox
[tomato.git] / release / src / router / busybox / e2fsprogs / ext2fs / cmp_bitmaps.c
blob7f78ff8042013a826fc2bfbcba01ac31564681cd
1 /* vi: set sw=4 ts=4: */
2 /*
3 * cmp_bitmaps.c --- routines to compare inode and block bitmaps.
5 * Copyright (C) 1995 Theodore Ts'o.
7 * %Begin-Header%
8 * This file may be redistributed under the terms of the GNU Public
9 * License.
10 * %End-Header%
13 #include <stdio.h>
14 #include <string.h>
15 #if HAVE_UNISTD_H
16 #include <unistd.h>
17 #endif
18 #include <fcntl.h>
19 #include <time.h>
20 #if HAVE_SYS_STAT_H
21 #include <sys/stat.h>
22 #endif
23 #if HAVE_SYS_TYPES_H
24 #include <sys/types.h>
25 #endif
27 #include "ext2_fs.h"
28 #include "ext2fs.h"
30 errcode_t ext2fs_compare_block_bitmap(ext2fs_block_bitmap bm1,
31 ext2fs_block_bitmap bm2)
33 blk_t i;
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;
49 return 0;
52 errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1,
53 ext2fs_inode_bitmap bm2)
55 ext2_ino_t i;
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;
71 return 0;