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>
30 * Reads a list of bad blocks from a FILE *
32 errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f,
33 ext2_badblocks_list *bb_list,
35 void (*invalid)(ext2_filsys fs,
46 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
49 retval = ext2fs_badblocks_list_create(bb_list, 10);
55 if (fgets(buf, sizeof(buf), f) == NULL)
57 count = sscanf(buf, "%u", &blockno);
61 ((blockno < fs->super->s_first_data_block) ||
62 (blockno >= fs->super->s_blocks_count))) {
64 (invalid)(fs, blockno, buf, priv_data);
67 retval = ext2fs_badblocks_list_add(*bb_list, blockno);
74 static void call_compat_invalid(ext2_filsys fs, blk_t blk,
75 char *badstr EXT2FS_ATTR((unused)),
78 void (*invalid)(ext2_filsys, blk_t);
80 invalid = (void (*)(ext2_filsys, blk_t)) priv_data;
87 * Reads a list of bad blocks from a FILE *
89 errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f,
90 ext2_badblocks_list *bb_list,
91 void (*invalid)(ext2_filsys fs, blk_t blk))
93 return ext2fs_read_bb_FILE2(fs, f, bb_list, (void *) invalid,