bitmap.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * bitmap.h - Defines for NTFS kernel bitmap handling. Part of the Linux-NTFS
  3. * project.
  4. *
  5. * Copyright (c) 2004 Anton Altaparmakov
  6. *
  7. * This program/include file is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as published
  9. * by the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program/include file is distributed in the hope that it will be
  13. * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  14. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program (in the main directory of the Linux-NTFS
  19. * distribution in the file COPYING); if not, write to the Free Software
  20. * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #ifndef _LINUX_NTFS_BITMAP_H
  23. #define _LINUX_NTFS_BITMAP_H
  24. #ifdef NTFS_RW
  25. #include <linux/fs.h>
  26. #include "types.h"
  27. extern int __ntfs_bitmap_set_bits_in_run(struct inode *vi, const s64 start_bit,
  28. const s64 count, const u8 value, const bool is_rollback);
  29. /**
  30. * ntfs_bitmap_set_bits_in_run - set a run of bits in a bitmap to a value
  31. * @vi: vfs inode describing the bitmap
  32. * @start_bit: first bit to set
  33. * @count: number of bits to set
  34. * @value: value to set the bits to (i.e. 0 or 1)
  35. *
  36. * Set @count bits starting at bit @start_bit in the bitmap described by the
  37. * vfs inode @vi to @value, where @value is either 0 or 1.
  38. *
  39. * Return 0 on success and -errno on error.
  40. */
  41. static inline int ntfs_bitmap_set_bits_in_run(struct inode *vi,
  42. const s64 start_bit, const s64 count, const u8 value)
  43. {
  44. return __ntfs_bitmap_set_bits_in_run(vi, start_bit, count, value,
  45. false);
  46. }
  47. /**
  48. * ntfs_bitmap_set_run - set a run of bits in a bitmap
  49. * @vi: vfs inode describing the bitmap
  50. * @start_bit: first bit to set
  51. * @count: number of bits to set
  52. *
  53. * Set @count bits starting at bit @start_bit in the bitmap described by the
  54. * vfs inode @vi.
  55. *
  56. * Return 0 on success and -errno on error.
  57. */
  58. static inline int ntfs_bitmap_set_run(struct inode *vi, const s64 start_bit,
  59. const s64 count)
  60. {
  61. return ntfs_bitmap_set_bits_in_run(vi, start_bit, count, 1);
  62. }
  63. /**
  64. * ntfs_bitmap_clear_run - clear a run of bits in a bitmap
  65. * @vi: vfs inode describing the bitmap
  66. * @start_bit: first bit to clear
  67. * @count: number of bits to clear
  68. *
  69. * Clear @count bits starting at bit @start_bit in the bitmap described by the
  70. * vfs inode @vi.
  71. *
  72. * Return 0 on success and -errno on error.
  73. */
  74. static inline int ntfs_bitmap_clear_run(struct inode *vi, const s64 start_bit,
  75. const s64 count)
  76. {
  77. return ntfs_bitmap_set_bits_in_run(vi, start_bit, count, 0);
  78. }
  79. /**
  80. * ntfs_bitmap_set_bit - set a bit in a bitmap
  81. * @vi: vfs inode describing the bitmap
  82. * @bit: bit to set
  83. *
  84. * Set bit @bit in the bitmap described by the vfs inode @vi.
  85. *
  86. * Return 0 on success and -errno on error.
  87. */
  88. static inline int ntfs_bitmap_set_bit(struct inode *vi, const s64 bit)
  89. {
  90. return ntfs_bitmap_set_run(vi, bit, 1);
  91. }
  92. /**
  93. * ntfs_bitmap_clear_bit - clear a bit in a bitmap
  94. * @vi: vfs inode describing the bitmap
  95. * @bit: bit to clear
  96. *
  97. * Clear bit @bit in the bitmap described by the vfs inode @vi.
  98. *
  99. * Return 0 on success and -errno on error.
  100. */
  101. static inline int ntfs_bitmap_clear_bit(struct inode *vi, const s64 bit)
  102. {
  103. return ntfs_bitmap_clear_run(vi, bit, 1);
  104. }
  105. #endif /* NTFS_RW */
  106. #endif /* defined _LINUX_NTFS_BITMAP_H */