Home | History | Annotate | Download | only in ext2fs

Lines Matching full:bitmap

2  * gen_bitmap.c --- Generic (32-bit) bitmap routines
37 char * bitmap;
56 void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
60 if (bitmap->description)
61 com_err(0, bitmap->base_error_code+code,
62 "#%lu for %s", arg, bitmap->description);
64 com_err(0, bitmap->base_error_code + code, "#%lu", arg);
68 static errcode_t check_magic(ext2fs_generic_bitmap bitmap)
70 if (!bitmap || !((bitmap->magic == EXT2_ET_MAGIC_GENERIC_BITMAP) ||
71 (bitmap->magic == EXT2_ET_MAGIC_INODE_BITMAP) ||
72 (bitmap->magic == EXT2_ET_MAGIC_BLOCK_BITMAP)))
82 ext2fs_generic_bitmap bitmap;
87 &bitmap);
91 bitmap->magic = magic;
92 bitmap->fs = fs;
93 bitmap->start = start;
94 bitmap->end = end;
95 bitmap->real_end = real_end;
98 bitmap->base_error_code = EXT2_ET_BAD_INODE_MARK;
101 bitmap->base_error_code = EXT2_ET_BAD_BLOCK_MARK;
104 bitmap->base_error_code = EXT2_ET_BAD_GENERIC_MARK;
107 retval = ext2fs_get_mem(strlen(descr)+1, &bitmap->description);
109 ext2fs_free_mem(&bitmap);
112 strcpy(bitmap->description, descr);
114 bitmap->description = 0;
116 size = (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1);
119 retval = ext2fs_get_mem(size, &bitmap->bitmap);
121 ext2fs_free_mem(&bitmap->description);
122 ext2fs_free_mem(&bitmap);
127 memcpy(bitmap->bitmap, init_map, size);
129 memset(bitmap->bitmap, 0, size);
130 *ret = bitmap;
150 src->description, src->bitmap,
154 void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap)
156 if (check_magic(bitmap))
159 bitmap->magic = 0;
160 if (bitmap->description) {
161 ext2fs_free_mem(&bitmap->description);
162 bitmap->description = 0;
164 if (bitmap->bitmap) {
165 ext2fs_free_mem(&bitmap->bitmap);
166 bitmap->bitmap = 0;
168 ext2fs_free_mem(&bitmap);
171 int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap,
174 if (!EXT2FS_IS_32_BITMAP(bitmap)) {
175 if (EXT2FS_IS_64_BITMAP(bitmap)) {
176 ext2fs_warn_bitmap32(bitmap, __func__);
177 return ext2fs_test_generic_bmap(bitmap, bitno);
186 if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
187 ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, bitno);
190 return ext2fs_test_bit(bitno - bitmap->start, bitmap->bitmap);
193 int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
196 if (!EXT2FS_IS_32_BITMAP(bitmap)) {
197 if (EXT2FS_IS_64_BITMAP(bitmap)) {
198 ext2fs_warn_bitmap32(bitmap, __func__);
199 return ext2fs_mark_generic_bmap(bitmap, bitno);
208 if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
209 ext2fs_warn_bitmap2(bitmap, EXT2FS_MARK_ERROR, bitno);
212 return ext2fs_set_bit(bitno - bitmap->start, bitmap->bitmap);
215 int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
218 if (!EXT2FS_IS_32_BITMAP(bitmap)) {
219 if (EXT2FS_IS_64_BITMAP(bitmap)) {
220 ext2fs_warn_bitmap32(bitmap, __func__);
221 return ext2fs_unmark_generic_bmap(bitmap, bitno);
230 if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
231 ext2fs_warn_bitmap2(bitmap, EXT2FS_UNMARK_ERROR, bitno);
234 return ext2fs_clear_bit(bitno - bitmap->start, bitmap->bitmap);
237 __u32 ext2fs_get_generic_bitmap_start(ext2fs_generic_bitmap bitmap)
239 if (!EXT2FS_IS_32_BITMAP(bitmap)) {
240 if (EXT2FS_IS_64_BITMAP(bitmap)) {
241 ext2fs_warn_bitmap32(bitmap, __func__);
242 return ext2fs_get_generic_bmap_start(bitmap);
251 return bitmap->start;
254 __u32 ext2fs_get_generic_bitmap_end(ext2fs_generic_bitmap bitmap)
256 if (!EXT2FS_IS_32_BITMAP(bitmap)) {
257 if (EXT2FS_IS_64_BITMAP(bitmap)) {
258 ext2fs_warn_bitmap32(bitmap, __func__);
259 return ext2fs_get_generic_bmap_end(bitmap);
267 return bitmap->end;
270 void ext2fs_clear_generic_bitmap(ext2fs_generic_bitmap bitmap)
272 if (!EXT2FS_IS_32_BITMAP(bitmap)) {
273 if (EXT2FS_IS_64_BITMAP(bitmap)) {
274 ext2fs_warn_bitmap32(bitmap, __func__);
275 ext2fs_clear_generic_bmap(bitmap);
285 memset(bitmap->bitmap, 0,
286 (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1));
289 errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap bitmap,
293 EXT2_CHECK_MAGIC(bitmap, magic);
295 if (end > bitmap->real_end)
298 *oend = bitmap->end;
299 bitmap->end = end;
315 * If we're expanding the bitmap, make sure all of the new
316 * parts of the bitmap are zero.
323 ext2fs_clear_bit(bitno - bmap->start, bmap->bitmap);
334 retval = ext2fs_resize_mem(size, new_size, &bmap->bitmap);
339 memset(bmap->bitmap + size, 0, new_size - size);
359 (memcmp(bm1->bitmap, bm2->bitmap,
379 ext2fs_set_bit(j, map->bitmap);
393 memcpy(out, bmap->bitmap + (start >> 3), (num+7) >> 3);
408 memcpy(bmap->bitmap + (start >> 3), in, (num+7) >> 3);
435 static int ext2fs_test_clear_generic_bitmap_range(ext2fs_generic_bitmap bitmap,
446 const char *ADDR = bitmap->bitmap;
448 start -= bitmap->start;
507 errcode_t ext2fs_find_first_zero_generic_bitmap(ext2fs_generic_bitmap bitmap,
513 if (start < bitmap->start || end > bitmap->end || start > end) {
514 ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, start);
519 b = ext2fs_test_bit(start - bitmap->start, bitmap->bitmap);
530 errcode_t ext2fs_find_first_set_generic_bitmap(ext2fs_generic_bitmap bitmap,
536 if (start < bitmap->start || end > bitmap->end || start > end) {
537 ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, start);
542 b = ext2fs_test_bit(start - bitmap->start, bitmap->bitmap);
553 int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
556 EXT2_CHECK_MAGIC(bitmap, EXT2_ET_MAGIC_BLOCK_BITMAP);
557 if ((block < bitmap->start) || (block+num-1 > bitmap->real_end)) {
559 block, bitmap->description);
563 bitmap, block, num);
566 int ext2fs_test_inode_bitmap_range(ext2fs_inode_bitmap bitmap,
569 EXT2_CHECK_MAGIC(bitmap, EXT2_ET_MAGIC_INODE_BITMAP);
570 if ((inode < bitmap->start) || (inode+num-1 > bitmap->real_end)) {
572 inode, bitmap->description);
576 bitmap, inode, num);
579 void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
584 if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
586 bitmap->description);
590 ext2fs_fast_set_bit(block + i - bitmap->start, bitmap->bitmap);
593 void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
598 if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
600 bitmap->description);
604 ext2fs_fast_clear_bit(block + i - bitmap->start,
605 bitmap->bitmap);