Lines Matching full:scan
48 ext2_inode_scan scan,
109 ext2_inode_scan scan;
134 retval = ext2fs_get_mem(sizeof(struct ext2_struct_inode_scan), &scan);
137 memset(scan, 0, sizeof(struct ext2_struct_inode_scan));
139 scan->magic = EXT2_ET_MAGIC_INODE_SCAN;
140 scan->fs = fs;
141 scan->inode_size = EXT2_INODE_SIZE(fs->super);
142 scan->bytes_left = 0;
143 scan->current_group = 0;
144 scan->groups_left = fs->group_desc_count - 1;
145 scan->inode_buffer_blocks = buffer_blocks ? buffer_blocks : 8;
146 scan->current_block = scan->fs->
147 group_desc[scan->current_group].bg_inode_table;
148 scan->inodes_left = EXT2_INODES_PER_GROUP(scan->fs->super);
149 scan->blocks_left = scan->fs->inode_blocks_per_group;
152 scan->inodes_left -=
153 fs->group_desc[scan->current_group].bg_itable_unused;
154 scan->blocks_left =
155 (scan->inodes_left +
156 (fs->blocksize / scan->inode_size - 1)) *
157 scan->inode_size / fs->blocksize;
159 retval = ext2fs_get_memalign(scan->inode_buffer_blocks * fs->blocksize,
160 fs->blocksize, &scan->inode_buffer);
161 scan->done_group = 0;
162 scan->done_group_data = 0;
163 scan->bad_block_ptr = 0;
165 ext2fs_free_mem(&scan);
168 retval = ext2fs_get_mem(scan->inode_size, &scan->temp_buffer);
170 ext2fs_free_mem(&scan->inode_buffer);
171 ext2fs_free_mem(&scan);
174 if (scan->fs->badblocks && scan->fs->badblocks->num)
175 scan->scan_flags |= EXT2_SF_CHK_BADBLOCKS;
178 scan->scan_flags |= EXT2_SF_DO_LAZY;
179 *ret_scan = scan;
183 void ext2fs_close_inode_scan(ext2_inode_scan scan)
185 if (!scan || (scan->magic != EXT2_ET_MAGIC_INODE_SCAN))
188 ext2fs_free_mem(&scan->inode_buffer);
189 scan->inode_buffer = NULL;
190 ext2fs_free_mem(&scan->temp_buffer);
191 scan->temp_buffer = NULL;
192 ext2fs_free_mem(&scan);
196 void ext2fs_set_inode_callback(ext2_inode_scan scan,
198 ext2_inode_scan scan,
203 if (!scan || (scan->magic != EXT2_ET_MAGIC_INODE_SCAN))
206 scan->done_group = done_group;
207 scan->done_group_data = done_group_data;
210 int ext2fs_inode_scan_flags(ext2_inode_scan scan, int set_flags,
215 if (!scan || (scan->magic != EXT2_ET_MAGIC_INODE_SCAN))
218 old_flags = scan->scan_flags;
219 scan->scan_flags &= ~clear_flags;
220 scan->scan_flags |= set_flags;
228 static errcode_t get_next_blockgroup(ext2_inode_scan scan)
230 ext2_filsys fs = scan->fs;
232 scan->current_group++;
233 scan->groups_left--;
235 scan->current_block =fs->group_desc[scan->current_group].bg_inode_table;
237 scan->current_inode = scan->current_group *
240 scan->bytes_left = 0;
241 scan->inodes_left = EXT2_INODES_PER_GROUP(fs->super);
242 scan->blocks_left = fs->inode_blocks_per_group;
245 scan->inodes_left -=
246 fs->group_desc[scan->current_group].bg_itable_unused;
247 scan->blocks_left =
248 (scan->inodes_left +
249 (fs->blocksize / scan->inode_size - 1)) *
250 scan->inode_size / fs->blocksize;
256 errcode_t ext2fs_inode_scan_goto_blockgroup(ext2_inode_scan scan,
259 scan->current_group = group - 1;
260 scan->groups_left = scan->fs->group_desc_count - group;
261 return get_next_blockgroup(scan);
271 static errcode_t check_for_inode_bad_blocks(ext2_inode_scan scan,
274 blk_t blk = scan->current_block;
275 badblocks_list bb = scan->fs->badblocks;
290 while (blk > bb->list[scan->bad_block_ptr]) {
291 if (++scan->bad_block_ptr >= bb->num) {
292 scan->scan_flags &= ~EXT2_SF_CHK_BADBLOCKS;
305 if (blk == bb->list[scan->bad_block_ptr]) {
306 scan->scan_flags |= EXT2_SF_BAD_INODE_BLK;
308 if (++scan->bad_block_ptr >= bb->num)
309 scan->scan_flags &= ~EXT2_SF_CHK_BADBLOCKS;
319 if ((blk + *num_blocks) > bb->list[scan->bad_block_ptr])
320 *num_blocks = (int) (bb->list[scan->bad_block_ptr] - blk);
329 static errcode_t get_next_blocks(ext2_inode_scan scan)
339 num_blocks = scan->inode_buffer_blocks;
340 if (num_blocks > scan->blocks_left)
341 num_blocks = scan->blocks_left;
347 if (scan->scan_flags & EXT2_SF_BAD_INODE_BLK) {
348 if (scan->bytes_left)
349 scan->scan_flags |= EXT2_SF_BAD_EXTRA_BYTES;
350 scan->scan_flags &= ~EXT2_SF_BAD_INODE_BLK;
356 if (scan->scan_flags & EXT2_SF_CHK_BADBLOCKS) {
357 retval = check_for_inode_bad_blocks(scan, &num_blocks);
362 if ((scan->scan_flags & EXT2_SF_BAD_INODE_BLK) ||
363 (scan->current_block == 0)) {
364 memset(scan->inode_buffer, 0,
365 (size_t) num_blocks * scan->fs->blocksize);
367 retval = io_channel_read_blk(scan->fs->io,
368 scan->current_block,
370 scan->inode_buffer);
374 scan->ptr = scan->inode_buffer;
375 scan->bytes_left = num_blocks * scan->fs->blocksize;
377 scan->blocks_left -= num_blocks;
378 if (scan->current_block)
379 scan->current_block += num_blocks;
390 static inline int is_empty_scan(ext2_inode_scan scan)
394 if (scan->bytes_left == 0)
397 for (i=0; i < scan->bytes_left; i++)
398 if (scan->ptr[i])
404 errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino,
410 EXT2_CHECK_MAGIC(scan, EXT2_ET_MAGIC_INODE_SCAN);
415 if (scan->inodes_left <= 0) {
417 if (scan->done_group) {
418 retval = (scan->done_group)
419 (scan->fs, scan, scan->current_group,
420 scan->done_group_data);
424 if (scan->groups_left <= 0) {
428 retval = get_next_blockgroup(scan);
436 if ((scan->scan_flags & EXT2_SF_DO_LAZY) &&
437 (scan->fs->group_desc[scan->current_group].bg_flags &
440 if (scan->inodes_left == 0)
442 if (scan->current_block == 0) {
443 if (scan->scan_flags & EXT2_SF_SKIP_MISSING_ITABLE) {
454 if (scan->bytes_left < scan->inode_size) {
455 memcpy(scan->temp_buffer, scan->ptr, scan->bytes_left);
456 extra_bytes = scan->bytes_left;
458 retval = get_next_blocks(scan);
466 if (is_empty_scan(scan))
473 memcpy(scan->temp_buffer+extra_bytes, scan->ptr,
474 scan->inode_size - extra_bytes);
475 scan->ptr += scan->inode_size - extra_bytes;
476 scan->bytes_left -= scan->inode_size - extra_bytes;
480 ext2fs_swap_inode_full(scan->fs,
482 (struct ext2_inode_large *) scan->temp_buffer,
485 *inode = *((struct ext2_inode *) scan->temp_buffer);
487 if (scan->scan_flags & EXT2_SF_BAD_EXTRA_BYTES)
489 scan->scan_flags &= ~EXT2_SF_BAD_EXTRA_BYTES;
493 ext2fs_swap_inode_full(scan->fs,
495 (struct ext2_inode_large *) scan->ptr,
498 memcpy(inode, scan->ptr, bufsize);
500 scan->ptr += scan->inode_size;
501 scan->bytes_left -= scan->inode_size;
502 if (scan->scan_flags & EXT2_SF_BAD_INODE_BLK)
506 scan->inodes_left--;
507 scan->current_inode++;
508 *ino = scan->current_inode;
512 errcode_t ext2fs_get_next_inode(ext2_inode_scan scan, ext2_ino_t *ino,
515 return ext2fs_get_next_inode_full(scan, ino, inode,