Lines Matching +full:byte +full:- +full:len
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * bitmap.c - NTFS kernel bitmap handling. Part of the Linux-NTFS project.
5 * Copyright (c) 2004-2005 Anton Altaparmakov
18 * __ntfs_bitmap_set_bits_in_run - set a run of bits in a bitmap to a value
31 * Return 0 on success and -errno on error.
41 int pos, len; in __ntfs_bitmap_set_bits_in_run() local
46 "value %u.%s", vi->i_ino, (unsigned long long)start_bit, in __ntfs_bitmap_set_bits_in_run()
54 * bits, i.e. @start_bit and @start_bit + @cnt - 1, respectively. in __ntfs_bitmap_set_bits_in_run()
57 end_index = (start_bit + cnt - 1) >> (3 + PAGE_SHIFT); in __ntfs_bitmap_set_bits_in_run()
60 mapping = vi->i_mapping; in __ntfs_bitmap_set_bits_in_run()
64 ntfs_error(vi->i_sb, "Failed to map first page (error " in __ntfs_bitmap_set_bits_in_run()
70 /* Set @pos to the position of the byte containing @start_bit. */ in __ntfs_bitmap_set_bits_in_run()
73 /* Calculate the position of @start_bit in the first byte. */ in __ntfs_bitmap_set_bits_in_run()
76 /* If the first byte is partial, modify the appropriate bits in it. */ in __ntfs_bitmap_set_bits_in_run()
78 u8 *byte = kaddr + pos; in __ntfs_bitmap_set_bits_in_run() local
80 cnt--; in __ntfs_bitmap_set_bits_in_run()
82 *byte |= 1 << bit++; in __ntfs_bitmap_set_bits_in_run()
84 *byte &= ~(1 << bit++); in __ntfs_bitmap_set_bits_in_run()
97 len = min_t(s64, cnt >> 3, PAGE_SIZE - pos); in __ntfs_bitmap_set_bits_in_run()
98 memset(kaddr + pos, value ? 0xff : 0, len); in __ntfs_bitmap_set_bits_in_run()
99 cnt -= len << 3; in __ntfs_bitmap_set_bits_in_run()
101 /* Update @len to point to the first not-done byte in the page. */ in __ntfs_bitmap_set_bits_in_run()
103 len += pos; in __ntfs_bitmap_set_bits_in_run()
121 len = min_t(s64, cnt >> 3, PAGE_SIZE); in __ntfs_bitmap_set_bits_in_run()
122 memset(kaddr, value ? 0xff : 0, len); in __ntfs_bitmap_set_bits_in_run()
123 cnt -= len << 3; in __ntfs_bitmap_set_bits_in_run()
126 * The currently mapped page is the last one. If the last byte is in __ntfs_bitmap_set_bits_in_run()
127 * partial, modify the appropriate bits in it. Note, @len is the in __ntfs_bitmap_set_bits_in_run()
128 * position of the last byte inside the page. in __ntfs_bitmap_set_bits_in_run()
131 u8 *byte; in __ntfs_bitmap_set_bits_in_run() local
136 byte = kaddr + len; in __ntfs_bitmap_set_bits_in_run()
137 while (bit--) { in __ntfs_bitmap_set_bits_in_run()
139 *byte |= 1 << bit; in __ntfs_bitmap_set_bits_in_run()
141 *byte &= ~(1 << bit); in __ntfs_bitmap_set_bits_in_run()
154 * - no pages are mapped in __ntfs_bitmap_set_bits_in_run()
155 * - @count - @cnt is the number of bits that have been modified in __ntfs_bitmap_set_bits_in_run()
160 pos = __ntfs_bitmap_set_bits_in_run(vi, start_bit, count - cnt, in __ntfs_bitmap_set_bits_in_run()
166 ntfs_error(vi->i_sb, "Failed to map subsequent page (error " in __ntfs_bitmap_set_bits_in_run()
170 ntfs_error(vi->i_sb, "Failed to map subsequent page (error " in __ntfs_bitmap_set_bits_in_run()
174 NVolSetErrors(NTFS_SB(vi->i_sb)); in __ntfs_bitmap_set_bits_in_run()