gen_bitmap.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * gen_bitmap.c --- Generic bitmap routines that used to be inlined.
  4. *
  5. * Copyright (C) 2001 Theodore Ts'o.
  6. *
  7. * %Begin-Header%
  8. * This file may be redistributed under the terms of the GNU Public
  9. * License.
  10. * %End-Header%
  11. */
  12. #include <stdio.h>
  13. #include <string.h>
  14. #if HAVE_UNISTD_H
  15. #include <unistd.h>
  16. #endif
  17. #include <fcntl.h>
  18. #include <time.h>
  19. #if HAVE_SYS_STAT_H
  20. #include <sys/stat.h>
  21. #endif
  22. #if HAVE_SYS_TYPES_H
  23. #include <sys/types.h>
  24. #endif
  25. #include "ext2_fs.h"
  26. #include "ext2fs.h"
  27. int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
  28. __u32 bitno)
  29. {
  30. if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
  31. ext2fs_warn_bitmap2(bitmap, EXT2FS_MARK_ERROR, bitno);
  32. return 0;
  33. }
  34. return ext2fs_set_bit(bitno - bitmap->start, bitmap->bitmap);
  35. }
  36. int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
  37. blk_t bitno)
  38. {
  39. if ((bitno < bitmap->start) || (bitno > bitmap->end)) {
  40. ext2fs_warn_bitmap2(bitmap, EXT2FS_UNMARK_ERROR, bitno);
  41. return 0;
  42. }
  43. return ext2fs_clear_bit(bitno - bitmap->start, bitmap->bitmap);
  44. }