1 /* vi: set sw=4 ts=4: */
3 * read_bb_file.c --- read a list of bad blocks from a FILE *
5 * Copyright (C) 1994, 1995, 2000 Theodore Ts'o.
8 * This file may be redistributed under the terms of the GNU Public
24 #include <sys/types.h>
31 * Reads a list of bad blocks from a FILE *
33 errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f,
34 ext2_badblocks_list *bb_list,
36 void (*invalid)(ext2_filsys fs,
47 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
50 retval = ext2fs_badblocks_list_create(bb_list, 10);
56 if (fgets(buf, sizeof(buf), f) == NULL)
58 count = sscanf(buf, "%u", &blockno);
62 ((blockno < fs->super->s_first_data_block) ||
63 (blockno >= fs->super->s_blocks_count))) {
65 (invalid)(fs, blockno, buf, priv_data);
68 retval = ext2fs_badblocks_list_add(*bb_list, blockno);
75 static void call_compat_invalid(ext2_filsys fs, blk_t blk,
76 char *badstr EXT2FS_ATTR((unused)),
79 void (*invalid)(ext2_filsys, blk_t);
81 invalid = (void (*)(ext2_filsys, blk_t)) priv_data;
88 * Reads a list of bad blocks from a FILE *
90 errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f,
91 ext2_badblocks_list *bb_list,
92 void (*invalid)(ext2_filsys fs, blk_t blk))
94 return ext2fs_read_bb_FILE2(fs, f, bb_list, (void *) invalid,