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 struct compat_struct {
75 void (*invalid)(ext2_filsys, blk_t);
78 static void call_compat_invalid(ext2_filsys fs, blk_t blk,
79 char *badstr EXT2FS_ATTR((unused)),
82 struct compat_struct *st;
84 st = (struct compat_struct *) priv_data;
86 (st->invalid)(fs, blk);
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 struct compat_struct st;
101 return ext2fs_read_bb_FILE2(fs, f, bb_list, &st,
102 call_compat_invalid);