2 * read_bb --- read the bad blocks inode
4 * Copyright (C) 1994 Theodore Ts'o. This file may be redistributed
5 * under the terms of the GNU Public License.
15 #include <sys/types.h>
18 #include <linux/ext2_fs.h>
22 struct read_bb_record {
23 badblocks_list bb_list;
28 * Helper function for ext2fs_read_bb_inode()
30 static int mark_bad_block(ext2_filsys fs, blk_t *block_nr,
31 int blockcnt, void *private)
33 struct read_bb_record *rb = (struct read_bb_record *) private;
38 rb->err = badblocks_list_add(rb->bb_list, *block_nr);
45 * Reads the current bad blocks from the bad blocks inode.
47 errcode_t ext2fs_read_bb_inode(ext2_filsys fs, badblocks_list *bb_list)
50 struct read_bb_record rb;
51 struct ext2_inode inode;
55 retval = ext2fs_read_inode(fs, EXT2_BAD_INO, &inode);
58 numblocks = (inode.i_blocks / (fs->blocksize / 512)) + 20;
59 retval = badblocks_list_create(bb_list, numblocks);
64 rb.bb_list = *bb_list;
66 retval = ext2fs_block_iterate(fs, EXT2_BAD_INO, 0, 0,