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