Lines Matching refs:bitmap

2  * gen_bitmap.c --- Generic (32-bit) bitmap routines
36 char * bitmap;
55 void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
59 if (bitmap->description)
60 com_err(0, bitmap->base_error_code+code,
61 "#%lu for %s", arg, bitmap->description);
63 com_err(0, bitmap->base_error_code + code, "#%lu", arg);
67 static errcode_t check_magic(ext2fs_generic_bitmap bitmap)
69 if (!bitmap || !((bitmap->magic == EXT2_ET_MAGIC_GENERIC_BITMAP) ||
70 (bitmap->magic == EXT2_ET_MAGIC_INODE_BITMAP) ||
71 (bitmap->magic == EXT2_ET_MAGIC_BLOCK_BITMAP)))
81 ext2fs_generic_bitmap bitmap;
86 &bitmap);
90 bitmap->magic = magic;
91 bitmap->fs = fs;
92 bitmap->start = start;
93 bitmap->end = end;
94 bitmap->real_end = real_end;
97 bitmap->base_error_code = EXT2_ET_BAD_INODE_MARK;
100 bitmap->base_error_code = EXT2_ET_BAD_BLOCK_MARK;
103 bitmap->base_error_code = EXT2_ET_BAD_GENERIC_MARK;
106 retval = ext2fs_get_mem(strlen(descr)+1, &bitmap->description);
108 ext2fs_free_mem(&bitmap);
111 strcpy(bitmap->description, descr);
113 bitmap->description = 0;
115 size = (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1);
118 retval = ext2fs_get_mem(size, &bitmap->bitmap);
120 ext2fs_free_mem(&bitmap->description);
121 ext2fs_free_mem(&bitmap);
126 memcpy(bitmap->bitmap, init_map, size);
128 memset(bitmap->bitmap, 0, size);
129 *ret = bitmap;
149 src->description, src->bitmap,
153 void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap)
155 if (check_magic(bitmap))
158 bitmap->magic = 0;
159 if (bitmap->description) {
160 ext2fs_free_mem(&bitmap->description);
161 bitmap->description = 0;
163 if (bitmap->bitmap) {
164 ext2fs_free_mem(&bitmap->bitmap);
165 bitmap->bitmap = 0;
167 ext2fs_free_mem(&bitmap);
170 int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap,
173 if (!EXT2FS_IS_32_BITMAP(bitmap)) {
174 if (EXT2FS_IS_64_BITMAP(bitmap)) {
175 ext2fs_warn_bitmap32(bitmap, __func__);
176 return ext2fs_test_generic_bmap(bitmap, bitno);
185 if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
186 ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, bitno);
189 return ext2fs_test_bit(bitno - bitmap->start, bitmap->bitmap);
192 int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
195 if (!EXT2FS_IS_32_BITMAP(bitmap)) {
196 if (EXT2FS_IS_64_BITMAP(bitmap)) {
197 ext2fs_warn_bitmap32(bitmap, __func__);
198 return ext2fs_mark_generic_bmap(bitmap, bitno);
207 if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
208 ext2fs_warn_bitmap2(bitmap, EXT2FS_MARK_ERROR, bitno);
211 return ext2fs_set_bit(bitno - bitmap->start, bitmap->bitmap);
214 int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
217 if (!EXT2FS_IS_32_BITMAP(bitmap)) {
218 if (EXT2FS_IS_64_BITMAP(bitmap)) {
219 ext2fs_warn_bitmap32(bitmap, __func__);
220 return ext2fs_unmark_generic_bmap(bitmap, bitno);
229 if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
230 ext2fs_warn_bitmap2(bitmap, EXT2FS_UNMARK_ERROR, bitno);
233 return ext2fs_clear_bit(bitno - bitmap->start, bitmap->bitmap);
236 __u32 ext2fs_get_generic_bitmap_start(ext2fs_generic_bitmap bitmap)
238 if (!EXT2FS_IS_32_BITMAP(bitmap)) {
239 if (EXT2FS_IS_64_BITMAP(bitmap)) {
240 ext2fs_warn_bitmap32(bitmap, __func__);
241 return ext2fs_get_generic_bmap_start(bitmap);
250 return bitmap->start;
253 __u32 ext2fs_get_generic_bitmap_end(ext2fs_generic_bitmap bitmap)
255 if (!EXT2FS_IS_32_BITMAP(bitmap)) {
256 if (EXT2FS_IS_64_BITMAP(bitmap)) {
257 ext2fs_warn_bitmap32(bitmap, __func__);
258 return ext2fs_get_generic_bmap_end(bitmap);
266 return bitmap->end;
269 void ext2fs_clear_generic_bitmap(ext2fs_generic_bitmap bitmap)
271 if (!EXT2FS_IS_32_BITMAP(bitmap)) {
272 if (EXT2FS_IS_64_BITMAP(bitmap)) {
273 ext2fs_warn_bitmap32(bitmap, __func__);
274 ext2fs_clear_generic_bmap(bitmap);
284 memset(bitmap->bitmap, 0,
285 (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1));
288 errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap bitmap,
292 EXT2_CHECK_MAGIC(bitmap, magic);
294 if (end > bitmap->real_end)
297 *oend = bitmap->end;
298 bitmap->end = end;
314 * If we're expanding the bitmap, make sure all of the new
315 * parts of the bitmap are zero.
322 ext2fs_clear_bit(bitno - bmap->start, bmap->bitmap);
333 retval = ext2fs_resize_mem(size, new_size, &bmap->bitmap);
338 memset(bmap->bitmap + size, 0, new_size - size);
358 (memcmp(bm1->bitmap, bm2->bitmap,
378 ext2fs_set_bit(j, map->bitmap);
392 memcpy(out, bmap->bitmap + (start >> 3), (num+7) >> 3);
407 memcpy(bmap->bitmap + (start >> 3), in, (num+7) >> 3);
434 static int ext2fs_test_clear_generic_bitmap_range(ext2fs_generic_bitmap bitmap,
445 const char *ADDR = bitmap->bitmap;
447 start -= bitmap->start;
506 errcode_t ext2fs_find_first_zero_generic_bitmap(ext2fs_generic_bitmap bitmap,
512 if (start < bitmap->start || end > bitmap->end || start > end) {
513 ext2fs_warn_bitmap2(bitmap, EXT2FS_TEST_ERROR, start);
518 b = ext2fs_test_bit(start - bitmap->start, bitmap->bitmap);
530 int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
533 EXT2_CHECK_MAGIC(bitmap, EXT2_ET_MAGIC_BLOCK_BITMAP);
534 if ((block < bitmap->start) || (block+num-1 > bitmap->real_end)) {
536 block, bitmap->description);
540 bitmap, block, num);
543 int ext2fs_test_inode_bitmap_range(ext2fs_inode_bitmap bitmap,
546 EXT2_CHECK_MAGIC(bitmap, EXT2_ET_MAGIC_INODE_BITMAP);
547 if ((inode < bitmap->start) || (inode+num-1 > bitmap->real_end)) {
549 inode, bitmap->description);
553 bitmap, inode, num);
556 void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
561 if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
563 bitmap->description);
567 ext2fs_fast_set_bit(block + i - bitmap->start, bitmap->bitmap);
570 void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
575 if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
577 bitmap->description);
581 ext2fs_fast_clear_bit(block + i - bitmap->start,
582 bitmap->bitmap);