^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * bitmap.h - Defines for NTFS kernel bitmap handling. Part of the Linux-NTFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * project.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (c) 2004 Anton Altaparmakov
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #ifndef _LINUX_NTFS_BITMAP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define _LINUX_NTFS_BITMAP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #ifdef NTFS_RW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "types.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) extern int __ntfs_bitmap_set_bits_in_run(struct inode *vi, const s64 start_bit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) const s64 count, const u8 value, const bool is_rollback);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * ntfs_bitmap_set_bits_in_run - set a run of bits in a bitmap to a value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * @vi: vfs inode describing the bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * @start_bit: first bit to set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * @count: number of bits to set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * @value: value to set the bits to (i.e. 0 or 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * Set @count bits starting at bit @start_bit in the bitmap described by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * vfs inode @vi to @value, where @value is either 0 or 1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * Return 0 on success and -errno on error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static inline int ntfs_bitmap_set_bits_in_run(struct inode *vi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) const s64 start_bit, const s64 count, const u8 value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) return __ntfs_bitmap_set_bits_in_run(vi, start_bit, count, value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * ntfs_bitmap_set_run - set a run of bits in a bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * @vi: vfs inode describing the bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * @start_bit: first bit to set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * @count: number of bits to set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * Set @count bits starting at bit @start_bit in the bitmap described by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * vfs inode @vi.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * Return 0 on success and -errno on error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) static inline int ntfs_bitmap_set_run(struct inode *vi, const s64 start_bit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) const s64 count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) return ntfs_bitmap_set_bits_in_run(vi, start_bit, count, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * ntfs_bitmap_clear_run - clear a run of bits in a bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * @vi: vfs inode describing the bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * @start_bit: first bit to clear
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * @count: number of bits to clear
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * Clear @count bits starting at bit @start_bit in the bitmap described by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * vfs inode @vi.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * Return 0 on success and -errno on error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) static inline int ntfs_bitmap_clear_run(struct inode *vi, const s64 start_bit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) const s64 count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) return ntfs_bitmap_set_bits_in_run(vi, start_bit, count, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * ntfs_bitmap_set_bit - set a bit in a bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * @vi: vfs inode describing the bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * @bit: bit to set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * Set bit @bit in the bitmap described by the vfs inode @vi.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * Return 0 on success and -errno on error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) static inline int ntfs_bitmap_set_bit(struct inode *vi, const s64 bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) return ntfs_bitmap_set_run(vi, bit, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * ntfs_bitmap_clear_bit - clear a bit in a bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * @vi: vfs inode describing the bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * @bit: bit to clear
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * Clear bit @bit in the bitmap described by the vfs inode @vi.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * Return 0 on success and -errno on error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) static inline int ntfs_bitmap_clear_bit(struct inode *vi, const s64 bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) return ntfs_bitmap_clear_run(vi, bit, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #endif /* NTFS_RW */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #endif /* defined _LINUX_NTFS_BITMAP_H */