Lines Matching refs:bb
35 ext2_u32_list bb;
38 retval = ext2fs_get_mem(sizeof(struct ext2_struct_u32_list), &bb);
41 memset(bb, 0, sizeof(struct ext2_struct_u32_list));
42 bb->magic = EXT2_ET_MAGIC_BADBLOCKS_LIST;
43 bb->size = size ? size : 10;
44 bb->num = num;
45 retval = ext2fs_get_array(bb->size, sizeof(blk_t), &bb->list);
47 ext2fs_free_mem(&bb);
51 memcpy(bb->list, list, bb->size * sizeof(blk_t));
53 memset(bb->list, 0, bb->size * sizeof(blk_t));
54 *ret = bb;
107 errcode_t ext2fs_u32_list_add(ext2_u32_list bb, __u32 blk)
113 EXT2_CHECK_MAGIC(bb, EXT2_ET_MAGIC_BADBLOCKS_LIST);
115 if (bb->num >= bb->size) {
116 old_size = bb->size * sizeof(__u32);
117 bb->size += 100;
118 retval = ext2fs_resize_mem(old_size, bb->size * sizeof(__u32),
119 &bb->list);
121 bb->size -= 100;
129 i = bb->num-1;
130 if ((bb->num != 0) && (bb->list[i] == blk))
132 if ((bb->num == 0) || (bb->list[i] < blk)) {
133 bb->list[bb->num++] = blk;
137 j = bb->num;
138 for (i=0; i < bb->num; i++) {
139 if (bb->list[i] == blk)
141 if (bb->list[i] > blk) {
146 for (i=bb->num; i > j; i--)
147 bb->list[i] = bb->list[i-1];
148 bb->list[j] = blk;
149 bb->num++;
153 errcode_t ext2fs_badblocks_list_add(ext2_badblocks_list bb, blk_t blk)
155 return ext2fs_u32_list_add((ext2_u32_list) bb, (__u32) blk);
162 int ext2fs_u32_list_find(ext2_u32_list bb, __u32 blk)
166 if (bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST)
169 if (bb->num == 0)
173 high = bb->num-1;
174 if (blk == bb->list[low])
176 if (blk == bb->list[high])
183 if (blk == bb->list[mid])
185 if (blk < bb->list[mid])
197 int ext2fs_u32_list_test(ext2_u32_list bb, __u32 blk)
199 if (ext2fs_u32_list_find(bb, blk) < 0)
205 int ext2fs_badblocks_list_test(ext2_badblocks_list bb, blk_t blk)
207 return ext2fs_u32_list_test((ext2_u32_list) bb, (__u32) blk);
214 int ext2fs_u32_list_del(ext2_u32_list bb, __u32 blk)
218 if (bb->num == 0)
221 remloc = ext2fs_u32_list_find(bb, blk);
225 for (i = remloc ; i < bb->num-1; i++)
226 bb->list[i] = bb->list[i+1];
227 bb->num--;
231 void ext2fs_badblocks_list_del(ext2_u32_list bb, __u32 blk)
233 ext2fs_u32_list_del(bb, blk);
236 errcode_t ext2fs_u32_list_iterate_begin(ext2_u32_list bb,
242 EXT2_CHECK_MAGIC(bb, EXT2_ET_MAGIC_BADBLOCKS_LIST);
249 iter->bb = bb;
255 errcode_t ext2fs_badblocks_list_iterate_begin(ext2_badblocks_list bb,
258 return ext2fs_u32_list_iterate_begin((ext2_u32_list) bb,
265 ext2_u32_list bb;
270 bb = iter->bb;
272 if (bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST)
275 if (iter->ptr < bb->num) {
276 *blk = bb->list[iter->ptr++];
295 iter->bb = 0;
324 int ext2fs_u32_list_count(ext2_u32_list bb)
326 return bb->num;