Whamcloud - gitweb
5550765c352dbc4a91f90cee80565836f8bbb9dc
[tools/e2fsprogs.git] / lib / ext2fs / write_bb_file.c
1 /*
2  * write_bb_file.c --- write a list of bad blocks to a FILE *
3  *
4  * Copyright (C) 1994, 1995 Theodore Ts'o.
5  *
6  * %Begin-Header%
7  * This file may be redistributed under the terms of the GNU Public
8  * License.
9  * %End-Header%
10  */
11
12 #include <stdio.h>
13
14 #if EXT2_FLAT_INCLUDES
15 #include "ext2_fs.h"
16 #else
17 #include <linux/ext2_fs.h>
18 #endif
19
20 #include "ext2fs.h"
21
22 errcode_t ext2fs_write_bb_FILE(ext2_badblocks_list bb_list,
23                                unsigned int flags,
24                                FILE *f)
25 {
26         badblocks_iterate       bb_iter;
27         blk_t                   blk;
28         errcode_t               retval;
29
30         retval = ext2fs_badblocks_list_iterate_begin(bb_list, &bb_iter);
31         if (retval)
32                 return retval;
33
34         while (ext2fs_badblocks_list_iterate(bb_iter, &blk)) {
35                 fprintf(f, "%d\n", blk);
36         }
37         ext2fs_badblocks_list_iterate_end(bb_iter);
38         return 0;
39 }