2 * read_bb_file.c --- read a list of bad blocks for a FILE *
4 * Copyright (C) 1994, 1995 Theodore Ts'o.
7 * This file may be redistributed under the terms of the GNU Public
19 #include <sys/types.h>
21 #include <linux/ext2_fs.h>
26 * Reads a list of bad blocks from a FILE *
28 errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f,
29 ext2_badblocks_list *bb_list,
30 void (*invalid)(ext2_filsys fs, blk_t blk))
37 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
40 retval = ext2fs_badblocks_list_create(bb_list, 10);
46 if (fgets(buf, sizeof(buf), f) == NULL)
48 count = sscanf(buf, "%u", &blockno);
51 if ((blockno < fs->super->s_first_data_block) ||
52 (blockno >= fs->super->s_blocks_count)) {
54 (invalid)(fs, blockno);
57 retval = ext2fs_badblocks_list_add(*bb_list, blockno);