Mirror of git://git.busybox.net/busybox with our patches on top
Source
errcode_t ext2fs_read_bb_inode(ext2_filsys fs, ext2_badblocks_list *bb_list)
/* vi: set sw=4 ts=4: */
/*
* read_bb --- read the bad blocks inode
*
* Copyright (C) 1994 Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Public
* License.
* %End-Header%
*/
struct read_bb_record {
ext2_badblocks_list bb_list;
errcode_t err;
};
/*
* Helper function for ext2fs_read_bb_inode()
*/
static int mark_bad_block(ext2_filsys fs, blk_t *block_nr,
e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)),
blk_t ref_block EXT2FS_ATTR((unused)),
int ref_offset EXT2FS_ATTR((unused)),
void *priv_data)
{
struct read_bb_record *rb = (struct read_bb_record *) priv_data;
if (blockcnt < 0)
return 0;
if ((*block_nr < fs->super->s_first_data_block) ||
(*block_nr >= fs->super->s_blocks_count))
return 0; /* Ignore illegal blocks */
rb->err = ext2fs_badblocks_list_add(rb->bb_list, *block_nr);
if (rb->err)
return BLOCK_ABORT;
return 0;
}
/*
* Reads the current bad blocks from the bad blocks inode.