• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * bitops.h --- Bitmap frobbing code.  The byte swapping routines are
3  * 	also included here.
4  *
5  * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
6  *
7  * %Begin-Header%
8  * This file may be redistributed under the terms of the GNU Library
9  * General Public License, version 2.
10  * %End-Header%
11  */
12 
13 #ifdef WORDS_BIGENDIAN
14 #define ext2fs_cpu_to_le64(x) ((__force __le64)ext2fs_swab64((__u64)(x)))
15 #define ext2fs_le64_to_cpu(x) ext2fs_swab64((__force __u64)(__le64)(x))
16 #define ext2fs_cpu_to_le32(x) ((__force __le32)ext2fs_swab32((__u32)(x)))
17 #define ext2fs_le32_to_cpu(x) ext2fs_swab32((__force __u32)(__le32)(x))
18 #define ext2fs_cpu_to_le16(x) ((__force __le16)ext2fs_swab16((__u16)(x)))
19 #define ext2fs_le16_to_cpu(x) ext2fs_swab16((__force __u16)(__le16)(x))
20 
21 #define ext2fs_cpu_to_be64(x) ((__force __be64)(__u64)(x))
22 #define ext2fs_be64_to_cpu(x) ((__force __u64)(__be64)(x))
23 #define ext2fs_cpu_to_be32(x) ((__force __be32)(__u32)(x))
24 #define ext2fs_be32_to_cpu(x) ((__force __u32)(__be32)(x))
25 #define ext2fs_cpu_to_be16(x) ((__force __be16)(__u16)(x))
26 #define ext2fs_be16_to_cpu(x) ((__force __u16)(__be16)(x))
27 #else
28 #define ext2fs_cpu_to_le64(x) ((__force __le64)(__u64)(x))
29 #define ext2fs_le64_to_cpu(x) ((__force __u64)(__le64)(x))
30 #define ext2fs_cpu_to_le32(x) ((__force __le32)(__u32)(x))
31 #define ext2fs_le32_to_cpu(x) ((__force __u32)(__le32)(x))
32 #define ext2fs_cpu_to_le16(x) ((__force __le16)(__u16)(x))
33 #define ext2fs_le16_to_cpu(x) ((__force __u16)(__le16)(x))
34 
35 #define ext2fs_cpu_to_be64(x) ((__force __be64)ext2fs_swab64((__u64)(x)))
36 #define ext2fs_be64_to_cpu(x) ext2fs_swab64((__force __u64)(__be64)(x))
37 #define ext2fs_cpu_to_be32(x) ((__force __be32)ext2fs_swab32((__u32)(x)))
38 #define ext2fs_be32_to_cpu(x) ext2fs_swab32((__force __u32)(__be32)(x))
39 #define ext2fs_cpu_to_be16(x) ((__force __be16)ext2fs_swab16((__u16)(x)))
40 #define ext2fs_be16_to_cpu(x) ext2fs_swab16((__force __u16)(__be16)(x))
41 #endif
42 
43 /*
44  * EXT2FS bitmap manipulation routines.
45  */
46 
47 /* Support for sending warning messages from the inline subroutines */
48 extern const char *ext2fs_block_string;
49 extern const char *ext2fs_inode_string;
50 extern const char *ext2fs_mark_string;
51 extern const char *ext2fs_unmark_string;
52 extern const char *ext2fs_test_string;
53 extern void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,
54 			       const char *description);
55 extern void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
56 				int code, unsigned long arg);
57 
58 #ifdef NO_INLINE_FUNCS
59 extern void ext2fs_fast_set_bit(unsigned int nr,void * addr);
60 extern void ext2fs_fast_clear_bit(unsigned int nr, void * addr);
61 extern void ext2fs_fast_set_bit64(__u64 nr,void * addr);
62 extern void ext2fs_fast_clear_bit64(__u64 nr, void * addr);
63 extern __u16 ext2fs_swab16(__u16 val);
64 extern __u32 ext2fs_swab32(__u32 val);
65 extern __u64 ext2fs_swab64(__u64 val);
66 
67 extern int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
68 extern int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
69 				       blk_t block);
70 extern int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
71 
72 extern int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode);
73 extern int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
74 				       ext2_ino_t inode);
75 extern int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode);
76 
77 extern void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,
78 					  blk_t block);
79 extern void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
80 					    blk_t block);
81 extern int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap,
82 					 blk_t block);
83 
84 extern void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
85 					  ext2_ino_t inode);
86 extern void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
87 					    ext2_ino_t inode);
88 extern int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
89 					 ext2_ino_t inode);
90 extern blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap);
91 extern ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap);
92 extern blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap);
93 extern ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap);
94 
95 extern void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
96 						blk_t block, int num);
97 extern void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
98 						  blk_t block, int num);
99 extern int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
100 					       blk_t block, int num);
101 #endif
102 
103 /* These functions routines moved to gen_bitmap.c */
104 extern void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
105 					   blk_t block, int num);
106 extern void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
107 					     blk_t block, int num);
108 extern int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
109 					  blk_t block, int num);
110 extern int ext2fs_test_inode_bitmap_range(ext2fs_inode_bitmap bitmap,
111 					  ext2_ino_t inode, int num);
112 extern int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
113 					 __u32 bitno);
114 extern int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
115 					   blk_t bitno);
116 extern int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap,
117 				      blk_t bitno);
118 extern int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
119 					  blk_t block, int num);
120 extern void ext2fs_set_bitmap_padding(ext2fs_generic_bitmap map);
121 extern __u32 ext2fs_get_generic_bitmap_start(ext2fs_generic_bitmap bitmap);
122 extern __u32 ext2fs_get_generic_bitmap_end(ext2fs_generic_bitmap bitmap);
123 
124 /* 64-bit versions */
125 
126 #ifdef NO_INLINE_FUNCS
127 extern int ext2fs_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
128 				     blk64_t block);
129 extern int ext2fs_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
130 				       blk64_t block);
131 extern int ext2fs_test_block_bitmap2(ext2fs_block_bitmap bitmap,
132 				     blk64_t block);
133 
134 extern int ext2fs_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
135 				     ext2_ino_t inode);
136 extern int ext2fs_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
137 				       ext2_ino_t inode);
138 extern int ext2fs_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
139 				     ext2_ino_t inode);
140 
141 extern void ext2fs_fast_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
142 					   blk64_t block);
143 extern void ext2fs_fast_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
144 					     blk64_t block);
145 extern int ext2fs_fast_test_block_bitmap2(ext2fs_block_bitmap bitmap,
146 					  blk64_t block);
147 
148 extern void ext2fs_fast_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
149 					   ext2_ino_t inode);
150 extern void ext2fs_fast_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
151 					    ext2_ino_t inode);
152 extern int ext2fs_fast_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
153 					  ext2_ino_t inode);
154 extern errcode_t ext2fs_find_first_zero_block_bitmap2(ext2fs_block_bitmap bitmap,
155 						      blk64_t start,
156 						      blk64_t end,
157 						      blk64_t *out);
158 extern errcode_t ext2fs_find_first_zero_inode_bitmap2(ext2fs_inode_bitmap bitmap,
159 						      ext2_ino_t start,
160 						      ext2_ino_t end,
161 						      ext2_ino_t *out);
162 extern errcode_t ext2fs_find_first_set_block_bitmap2(ext2fs_block_bitmap bitmap,
163 						     blk64_t start,
164 						     blk64_t end,
165 						     blk64_t *out);
166 extern errcode_t ext2fs_find_first_set_inode_bitmap2(ext2fs_inode_bitmap bitmap,
167 						      ext2_ino_t start,
168 						      ext2_ino_t end,
169 						      ext2_ino_t *out);
170 extern blk64_t ext2fs_get_block_bitmap_start2(ext2fs_block_bitmap bitmap);
171 extern ext2_ino_t ext2fs_get_inode_bitmap_start2(ext2fs_inode_bitmap bitmap);
172 extern blk64_t ext2fs_get_block_bitmap_end2(ext2fs_block_bitmap bitmap);
173 extern ext2_ino_t ext2fs_get_inode_bitmap_end2(ext2fs_inode_bitmap bitmap);
174 
175 extern int ext2fs_fast_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
176 						blk64_t block,
177 						unsigned int num);
178 extern void ext2fs_fast_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
179 						 blk64_t block,
180 						 unsigned int num);
181 extern void ext2fs_fast_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
182 						   blk64_t block,
183 						   unsigned int num);
184 #endif
185 
186 /* These routines moved to gen_bitmap64.c */
187 extern void ext2fs_clear_generic_bmap(ext2fs_generic_bitmap bitmap);
188 extern errcode_t ext2fs_compare_generic_bmap(errcode_t neq,
189 					     ext2fs_generic_bitmap bm1,
190 					     ext2fs_generic_bitmap bm2);
191 extern void ext2fs_set_generic_bmap_padding(ext2fs_generic_bitmap bmap);
192 extern int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap,
193 				    blk64_t bitno);
194 extern int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap,
195 				      blk64_t bitno);
196 extern int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap,
197 				    blk64_t bitno);
198 extern int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
199 					   blk64_t block, unsigned int num);
200 extern __u64 ext2fs_get_generic_bmap_start(ext2fs_generic_bitmap bitmap);
201 extern __u64 ext2fs_get_generic_bmap_end(ext2fs_generic_bitmap bitmap);
202 extern int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
203 					   blk64_t block, unsigned int num);
204 extern void ext2fs_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
205 					    blk64_t block, unsigned int num);
206 extern void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
207 					      blk64_t block, unsigned int num);
208 extern errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap,
209 						     __u64 start, __u64 end,
210 						     __u64 *out);
211 extern errcode_t ext2fs_find_first_set_generic_bmap(ext2fs_generic_bitmap bitmap,
212 						    __u64 start, __u64 end,
213 						    __u64 *out);
214 
215 /*
216  * The inline routines themselves...
217  *
218  * If NO_INLINE_FUNCS is defined, then we won't try to do inline
219  * functions at all; they will be included as normal functions in
220  * inline.c
221  */
222 
223 #if (defined(INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
224 #ifdef INCLUDE_INLINE_FUNCS
225 #if (__STDC_VERSION__ >= 199901L)
226 #define _INLINE_ extern inline
227 #else
228 #define _INLINE_ inline
229 #endif
230 #else /* !INCLUDE_INLINE FUNCS */
231 #if (__STDC_VERSION__ >= 199901L)
232 #define _INLINE_ inline
233 #else /* not C99 */
234 #ifdef __GNUC__
235 #define _INLINE_ extern __inline__
236 #else				/* For Watcom C */
237 #define _INLINE_ extern inline
238 #endif /* __GNUC__ */
239 #endif /* __STDC_VERSION__ >= 199901L */
240 #endif /* INCLUDE_INLINE_FUNCS */
241 
242 /*
243  * Fast bit set/clear functions that doesn't need to return the
244  * previous bit value.
245  */
246 
ext2fs_fast_set_bit(unsigned int nr,void * addr)247 _INLINE_ void ext2fs_fast_set_bit(unsigned int nr,void * addr)
248 {
249 	unsigned char	*ADDR = (unsigned char *) addr;
250 
251 	ADDR += nr >> 3;
252 	*ADDR |= (unsigned char) (1 << (nr & 0x07));
253 }
254 
ext2fs_fast_clear_bit(unsigned int nr,void * addr)255 _INLINE_ void ext2fs_fast_clear_bit(unsigned int nr, void * addr)
256 {
257 	unsigned char	*ADDR = (unsigned char *) addr;
258 
259 	ADDR += nr >> 3;
260 	*ADDR &= (unsigned char) ~(1 << (nr & 0x07));
261 }
262 
263 
ext2fs_fast_set_bit64(__u64 nr,void * addr)264 _INLINE_ void ext2fs_fast_set_bit64(__u64 nr, void * addr)
265 {
266 	unsigned char	*ADDR = (unsigned char *) addr;
267 
268 	ADDR += nr >> 3;
269 	*ADDR |= (unsigned char) (1 << (nr & 0x07));
270 }
271 
ext2fs_fast_clear_bit64(__u64 nr,void * addr)272 _INLINE_ void ext2fs_fast_clear_bit64(__u64 nr, void * addr)
273 {
274 	unsigned char	*ADDR = (unsigned char *) addr;
275 
276 	ADDR += nr >> 3;
277 	*ADDR &= (unsigned char) ~(1 << (nr & 0x07));
278 }
279 
ext2fs_swab16(__u16 val)280 _INLINE_ __u16 ext2fs_swab16(__u16 val)
281 {
282 	return (val >> 8) | (__u16) (val << 8);
283 }
284 
ext2fs_swab32(__u32 val)285 _INLINE_ __u32 ext2fs_swab32(__u32 val)
286 {
287 	return ((val>>24) | ((val>>8)&0xFF00) |
288 		((val<<8)&0xFF0000) | (val<<24));
289 }
290 
ext2fs_swab64(__u64 val)291 _INLINE_ __u64 ext2fs_swab64(__u64 val)
292 {
293 	return (ext2fs_swab32((__u32) (val >> 32)) |
294 		(((__u64)ext2fs_swab32(val & 0xFFFFFFFFUL)) << 32));
295 }
296 
ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap,blk_t block)297 _INLINE_ int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap,
298 				       blk_t block)
299 {
300 	return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
301 					  block);
302 }
303 
ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap,blk_t block)304 _INLINE_ int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
305 					 blk_t block)
306 {
307 	return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
308 					    block);
309 }
310 
ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap,blk_t block)311 _INLINE_ int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap,
312 				       blk_t block)
313 {
314 	return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
315 					  block);
316 }
317 
ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)318 _INLINE_ int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
319 				       ext2_ino_t inode)
320 {
321 	return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
322 					  inode);
323 }
324 
ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)325 _INLINE_ int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
326 					 ext2_ino_t inode)
327 {
328 	return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
329 				     inode);
330 }
331 
ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)332 _INLINE_ int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
333 				       ext2_ino_t inode)
334 {
335 	return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
336 					  inode);
337 }
338 
ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,blk_t block)339 _INLINE_ void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,
340 					    blk_t block)
341 {
342 	ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, block);
343 }
344 
ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap,blk_t block)345 _INLINE_ void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
346 					      blk_t block)
347 {
348 	ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, block);
349 }
350 
ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap,blk_t block)351 _INLINE_ int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap,
352 					    blk_t block)
353 {
354 	return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
355 					  block);
356 }
357 
ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)358 _INLINE_ void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
359 					    ext2_ino_t inode)
360 {
361 	ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode);
362 }
363 
ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)364 _INLINE_ void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
365 					      ext2_ino_t inode)
366 {
367 	ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode);
368 }
369 
ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)370 _INLINE_ int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
371 					   ext2_ino_t inode)
372 {
373 	return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
374 					  inode);
375 }
376 
ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap)377 _INLINE_ blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap)
378 {
379 	return ext2fs_get_generic_bitmap_start((ext2fs_generic_bitmap) bitmap);
380 }
381 
ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap)382 _INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap)
383 {
384 	return ext2fs_get_generic_bitmap_start((ext2fs_generic_bitmap) bitmap);
385 }
386 
ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap)387 _INLINE_ blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap)
388 {
389 	return ext2fs_get_generic_bitmap_end((ext2fs_generic_bitmap) bitmap);
390 }
391 
ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap)392 _INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap)
393 {
394 	return ext2fs_get_generic_bitmap_end((ext2fs_generic_bitmap) bitmap);
395 }
396 
ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,blk_t block,int num)397 _INLINE_ int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
398 						 blk_t block, int num)
399 {
400 	return ext2fs_test_block_bitmap_range(bitmap, block, num);
401 }
402 
ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,blk_t block,int num)403 _INLINE_ void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
404 						  blk_t block, int num)
405 {
406 	ext2fs_mark_block_bitmap_range(bitmap, block, num);
407 }
408 
ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,blk_t block,int num)409 _INLINE_ void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
410 						    blk_t block, int num)
411 {
412 	ext2fs_unmark_block_bitmap_range(bitmap, block, num);
413 }
414 
415 /* 64-bit versions */
416 
ext2fs_mark_block_bitmap2(ext2fs_block_bitmap bitmap,blk64_t block)417 _INLINE_ int ext2fs_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
418 				       blk64_t block)
419 {
420 	return ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap,
421 					block);
422 }
423 
ext2fs_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,blk64_t block)424 _INLINE_ int ext2fs_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
425 					 blk64_t block)
426 {
427 	return ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
428 }
429 
ext2fs_test_block_bitmap2(ext2fs_block_bitmap bitmap,blk64_t block)430 _INLINE_ int ext2fs_test_block_bitmap2(ext2fs_block_bitmap bitmap,
431 				       blk64_t block)
432 {
433 	return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
434 					block);
435 }
436 
ext2fs_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)437 _INLINE_ int ext2fs_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
438 				       ext2_ino_t inode)
439 {
440 	return ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap,
441 					inode);
442 }
443 
ext2fs_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)444 _INLINE_ int ext2fs_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
445 					 ext2_ino_t inode)
446 {
447 	return ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap,
448 					  inode);
449 }
450 
ext2fs_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)451 _INLINE_ int ext2fs_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
452 				       ext2_ino_t inode)
453 {
454 	return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
455 					inode);
456 }
457 
ext2fs_fast_mark_block_bitmap2(ext2fs_block_bitmap bitmap,blk64_t block)458 _INLINE_ void ext2fs_fast_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
459 					     blk64_t block)
460 {
461 	ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
462 }
463 
ext2fs_fast_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,blk64_t block)464 _INLINE_ void ext2fs_fast_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
465 					       blk64_t block)
466 {
467 	ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
468 }
469 
ext2fs_fast_test_block_bitmap2(ext2fs_block_bitmap bitmap,blk64_t block)470 _INLINE_ int ext2fs_fast_test_block_bitmap2(ext2fs_block_bitmap bitmap,
471 					    blk64_t block)
472 {
473 	return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
474 					block);
475 }
476 
ext2fs_fast_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)477 _INLINE_ void ext2fs_fast_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
478 					     ext2_ino_t inode)
479 {
480 	ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap, inode);
481 }
482 
ext2fs_fast_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)483 _INLINE_ void ext2fs_fast_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
484 					       ext2_ino_t inode)
485 {
486 	ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, inode);
487 }
488 
ext2fs_fast_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)489 _INLINE_ int ext2fs_fast_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
490 					    ext2_ino_t inode)
491 {
492 	return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
493 					inode);
494 }
495 
ext2fs_find_first_zero_block_bitmap2(ext2fs_block_bitmap bitmap,blk64_t start,blk64_t end,blk64_t * out)496 _INLINE_ errcode_t ext2fs_find_first_zero_block_bitmap2(ext2fs_block_bitmap bitmap,
497 							blk64_t start,
498 							blk64_t end,
499 							blk64_t *out)
500 {
501 	__u64 o;
502 	errcode_t rv;
503 
504 	rv = ext2fs_find_first_zero_generic_bmap((ext2fs_generic_bitmap) bitmap,
505 						 start, end, &o);
506 	if (!rv)
507 		*out = o;
508 	return rv;
509 }
510 
ext2fs_find_first_zero_inode_bitmap2(ext2fs_inode_bitmap bitmap,ext2_ino_t start,ext2_ino_t end,ext2_ino_t * out)511 _INLINE_ errcode_t ext2fs_find_first_zero_inode_bitmap2(ext2fs_inode_bitmap bitmap,
512 							ext2_ino_t start,
513 							ext2_ino_t end,
514 							ext2_ino_t *out)
515 {
516 	__u64 o;
517 	errcode_t rv;
518 
519 	rv = ext2fs_find_first_zero_generic_bmap((ext2fs_generic_bitmap) bitmap,
520 						 start, end, &o);
521 	if (!rv)
522 		*out = (ext2_ino_t) o;
523 	return rv;
524 }
525 
ext2fs_find_first_set_block_bitmap2(ext2fs_block_bitmap bitmap,blk64_t start,blk64_t end,blk64_t * out)526 _INLINE_ errcode_t ext2fs_find_first_set_block_bitmap2(ext2fs_block_bitmap bitmap,
527 						       blk64_t start,
528 						       blk64_t end,
529 						       blk64_t *out)
530 {
531 	__u64 o;
532 	errcode_t rv;
533 
534 	rv = ext2fs_find_first_set_generic_bmap((ext2fs_generic_bitmap) bitmap,
535 						start, end, &o);
536 	if (!rv)
537 		*out = o;
538 	return rv;
539 }
540 
ext2fs_find_first_set_inode_bitmap2(ext2fs_inode_bitmap bitmap,ext2_ino_t start,ext2_ino_t end,ext2_ino_t * out)541 _INLINE_ errcode_t ext2fs_find_first_set_inode_bitmap2(ext2fs_inode_bitmap bitmap,
542 						       ext2_ino_t start,
543 						       ext2_ino_t end,
544 						       ext2_ino_t *out)
545 {
546 	__u64 o;
547 	errcode_t rv;
548 
549 	rv = ext2fs_find_first_set_generic_bmap((ext2fs_generic_bitmap) bitmap,
550 						start, end, &o);
551 	if (!rv)
552 		*out = (ext2_ino_t) o;
553 	return rv;
554 }
555 
ext2fs_get_block_bitmap_start2(ext2fs_block_bitmap bitmap)556 _INLINE_ blk64_t ext2fs_get_block_bitmap_start2(ext2fs_block_bitmap bitmap)
557 {
558 	return ext2fs_get_generic_bmap_start((ext2fs_generic_bitmap) bitmap);
559 }
560 
ext2fs_get_inode_bitmap_start2(ext2fs_inode_bitmap bitmap)561 _INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_start2(ext2fs_inode_bitmap bitmap)
562 {
563 	return (ext2_ino_t) ext2fs_get_generic_bmap_start((ext2fs_generic_bitmap) bitmap);
564 }
565 
ext2fs_get_block_bitmap_end2(ext2fs_block_bitmap bitmap)566 _INLINE_ blk64_t ext2fs_get_block_bitmap_end2(ext2fs_block_bitmap bitmap)
567 {
568 	return ext2fs_get_generic_bmap_end((ext2fs_generic_bitmap) bitmap);
569 }
570 
ext2fs_get_inode_bitmap_end2(ext2fs_inode_bitmap bitmap)571 _INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_end2(ext2fs_inode_bitmap bitmap)
572 {
573 	return (ext2_ino_t) ext2fs_get_generic_bmap_end((ext2fs_generic_bitmap) bitmap);
574 }
575 
ext2fs_fast_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,blk64_t block,unsigned int num)576 _INLINE_ int ext2fs_fast_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
577 						  blk64_t block,
578 						  unsigned int num)
579 {
580 	return ext2fs_test_block_bitmap_range2(bitmap, block, num);
581 }
582 
ext2fs_fast_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,blk64_t block,unsigned int num)583 _INLINE_ void ext2fs_fast_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
584 						   blk64_t block,
585 						   unsigned int num)
586 {
587 	ext2fs_mark_block_bitmap_range2(bitmap, block, num);
588 }
589 
ext2fs_fast_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,blk64_t block,unsigned int num)590 _INLINE_ void ext2fs_fast_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
591 						     blk64_t block,
592 						     unsigned int num)
593 {
594 	ext2fs_unmark_block_bitmap_range2(bitmap, block, num);
595 }
596 
597 #undef _INLINE_
598 #endif
599 
600 extern int ext2fs_set_bit(unsigned int nr,void * addr);
601 extern int ext2fs_clear_bit(unsigned int nr, void * addr);
602 extern int ext2fs_test_bit(unsigned int nr, const void * addr);
603 extern int ext2fs_set_bit64(__u64 nr,void * addr);
604 extern int ext2fs_clear_bit64(__u64 nr, void * addr);
605 extern int ext2fs_test_bit64(__u64 nr, const void * addr);
606 extern unsigned int ext2fs_bitcount(const void *addr, unsigned int nbytes);
607