3
0

gen_bitmap.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * gen_bitmap.c --- Generic bitmap routines that used to be inlined.
  3. *
  4. * Copyright (C) 2001 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 <string.h>
  13. #if HAVE_UNISTD_H
  14. #include <unistd.h>
  15. #endif
  16. #include <fcntl.h>
  17. #include <time.h>
  18. #if HAVE_SYS_STAT_H
  19. #include <sys/stat.h>
  20. #endif
  21. #if HAVE_SYS_TYPES_H
  22. #include <sys/types.h>
  23. #endif
  24. #include "ext2_fs.h"
  25. #include "ext2fs.h"
  26. int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
  27. __u32 bitno)
  28. {
  29. if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
  30. ext2fs_warn_bitmap2(bitmap, EXT2FS_MARK_ERROR, bitno);
  31. return 0;
  32. }
  33. return ext2fs_set_bit(bitno - bitmap->start, bitmap->bitmap);
  34. }
  35. int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
  36. blk_t bitno)
  37. {
  38. if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
  39. ext2fs_warn_bitmap2(bitmap, EXT2FS_UNMARK_ERROR, bitno);
  40. return 0;
  41. }
  42. return ext2fs_clear_bit(bitno - bitmap->start, bitmap->bitmap);
  43. }