2 * read_bb_file.c --- read a list of bad blocks from a FILE *
4 * Copyright (C) 1994, 1995, 2000 Theodore Ts'o.
7 * This file may be redistributed under the terms of the GNU Public
23 #include <sys/types.h>
26 #if EXT2_FLAT_INCLUDES
29 #include <linux/ext2_fs.h>
35 * Reads a list of bad blocks from a FILE *
37 errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f,
38 ext2_badblocks_list *bb_list,
40 void (*invalid)(ext2_filsys fs,
51 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
54 retval = ext2fs_badblocks_list_create(bb_list, 10);
60 if (fgets(buf, sizeof(buf), f) == NULL)
62 count = sscanf(buf, "%u", &blockno);
66 ((blockno < fs->super->s_first_data_block) ||
67 (blockno >= fs->super->s_blocks_count))) {
69 (invalid)(fs, blockno, buf, private);
72 retval = ext2fs_badblocks_list_add(*bb_list, blockno);
79 static void call_compat_invalid(ext2_filsys fs, blk_t blk,
80 char *badstr, void *private)
82 void (*invalid)(ext2_filsys, blk_t);
84 invalid = (void (*)(ext2_filsys, blk_t)) private;
91 * Reads a list of bad blocks from a FILE *
93 errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f,
94 ext2_badblocks_list *bb_list,
95 void (*invalid)(ext2_filsys fs, blk_t blk))
97 return ext2fs_read_bb_FILE2(fs, f, bb_list, (void *) invalid,