write_bb_file.c 732 B

12345678910111213141516171819202122232425262728293031323334
  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. #include <stdio.h>
  12. #include "ext2_fs.h"
  13. #include "ext2fs.h"
  14. errcode_t ext2fs_write_bb_FILE(ext2_badblocks_list bb_list,
  15. unsigned int flags EXT2FS_ATTR((unused)),
  16. FILE *f)
  17. {
  18. badblocks_iterate bb_iter;
  19. blk_t blk;
  20. errcode_t retval;
  21. retval = ext2fs_badblocks_list_iterate_begin(bb_list, &bb_iter);
  22. if (retval)
  23. return retval;
  24. while (ext2fs_badblocks_list_iterate(bb_iter, &blk)) {
  25. fprintf(f, "%d\n", blk);
  26. }
  27. ext2fs_badblocks_list_iterate_end(bb_iter);
  28. return 0;
  29. }