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 #ifdef NO_INLINE_FUNCS 223 #if (defined(__GNUC__) && (defined(__i386__) || defined(__i486__) || \ 224 defined(__i586__))) 225 /* This prevents bitops.c from trying to include the C */ 226 /* function version of these functions */ 227 #define _EXT2_HAVE_ASM_BITOPS_ 228 #endif 229 #endif /* NO_INLINE_FUNCS */ 230 231 #if (defined(INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS)) 232 #ifdef INCLUDE_INLINE_FUNCS 233 #if (__STDC_VERSION__ >= 199901L) 234 #define _INLINE_ extern inline 235 #else 236 #define _INLINE_ inline 237 #endif 238 #else /* !INCLUDE_INLINE FUNCS */ 239 #if (__STDC_VERSION__ >= 199901L) 240 #define _INLINE_ inline 241 #else /* not C99 */ 242 #ifdef __GNUC__ 243 #define _INLINE_ extern __inline__ 244 #else /* For Watcom C */ 245 #define _INLINE_ extern inline 246 #endif /* __GNUC__ */ 247 #endif /* __STDC_VERSION__ >= 199901L */ 248 #endif /* INCLUDE_INLINE_FUNCS */ 249 250 /* 251 * Fast bit set/clear functions that doesn't need to return the 252 * previous bit value. 253 */ 254 255 _INLINE_ void ext2fs_fast_set_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 _INLINE_ void ext2fs_fast_clear_bit(unsigned int nr, void * addr) 264 { 265 unsigned char *ADDR = (unsigned char *) addr; 266 267 ADDR += nr >> 3; 268 *ADDR &= (unsigned char) ~(1 << (nr & 0x07)); 269 } 270 271 272 _INLINE_ void ext2fs_fast_set_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 280 _INLINE_ void ext2fs_fast_clear_bit64(__u64 nr, void * addr) 281 { 282 unsigned char *ADDR = (unsigned char *) addr; 283 284 ADDR += nr >> 3; 285 *ADDR &= (unsigned char) ~(1 << (nr & 0x07)); 286 } 287 288 289 #if ((defined __GNUC__) && !defined(_EXT2_USE_C_VERSIONS_) && \ 290 (defined(__i386__) || defined(__i486__) || defined(__i586__))) 291 292 #define _EXT2_HAVE_ASM_BITOPS_ 293 #define _EXT2_HAVE_ASM_SWAB_ 294 295 /* 296 * These are done by inline assembly for speed reasons..... 297 * 298 * All bitoperations return 0 if the bit was cleared before the 299 * operation and != 0 if it was not. Bit 0 is the LSB of addr; bit 32 300 * is the LSB of (addr+1). 301 */ 302 303 /* 304 * Some hacks to defeat gcc over-optimizations.. 305 */ 306 struct __dummy_h { unsigned long a[100]; }; 307 #define EXT2FS_ADDR (*(struct __dummy_h *) addr) 308 #define EXT2FS_CONST_ADDR (*(const struct __dummy_h *) addr) 309 310 _INLINE_ int ext2fs_set_bit(unsigned int nr, void * addr) 311 { 312 int oldbit; 313 314 addr = (void *) (((unsigned char *) addr) + (nr >> 3)); 315 __asm__ __volatile__("btsl %2,%1\n\tsbbl %0,%0" 316 :"=r" (oldbit),"+m" (EXT2FS_ADDR) 317 :"r" (nr & 7)); 318 return oldbit; 319 } 320 321 _INLINE_ int ext2fs_clear_bit(unsigned int nr, void * addr) 322 { 323 int oldbit; 324 325 addr = (void *) (((unsigned char *) addr) + (nr >> 3)); 326 __asm__ __volatile__("btrl %2,%1\n\tsbbl %0,%0" 327 :"=r" (oldbit),"+m" (EXT2FS_ADDR) 328 :"r" (nr & 7)); 329 return oldbit; 330 } 331 332 _INLINE_ int ext2fs_test_bit(unsigned int nr, const void * addr) 333 { 334 int oldbit; 335 336 addr = (const void *) (((const unsigned char *) addr) + (nr >> 3)); 337 __asm__ __volatile__("btl %2,%1\n\tsbbl %0,%0" 338 :"=r" (oldbit) 339 :"m" (EXT2FS_CONST_ADDR),"r" (nr & 7)); 340 return oldbit; 341 } 342 343 _INLINE_ __u32 ext2fs_swab32(__u32 val) 344 { 345 #ifdef EXT2FS_REQUIRE_486 346 __asm__("bswap %0" : "=r" (val) : "0" (val)); 347 #else 348 __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */ 349 "rorl $16,%0\n\t" /* swap words */ 350 "xchgb %b0,%h0" /* swap higher bytes */ 351 :"=q" (val) 352 : "0" (val)); 353 #endif 354 return val; 355 } 356 357 _INLINE_ __u16 ext2fs_swab16(__u16 val) 358 { 359 __asm__("xchgb %b0,%h0" /* swap bytes */ \ 360 : "=q" (val) \ 361 : "0" (val)); \ 362 return val; 363 } 364 365 #undef EXT2FS_ADDR 366 367 #endif /* i386 */ 368 369 370 #if !defined(_EXT2_HAVE_ASM_SWAB_) 371 372 _INLINE_ __u16 ext2fs_swab16(__u16 val) 373 { 374 return (val >> 8) | (__u16) (val << 8); 375 } 376 377 _INLINE_ __u32 ext2fs_swab32(__u32 val) 378 { 379 return ((val>>24) | ((val>>8)&0xFF00) | 380 ((val<<8)&0xFF0000) | (val<<24)); 381 } 382 383 #endif /* !_EXT2_HAVE_ASM_SWAB */ 384 385 _INLINE_ __u64 ext2fs_swab64(__u64 val) 386 { 387 return (ext2fs_swab32((__u32) (val >> 32)) | 388 (((__u64)ext2fs_swab32(val & 0xFFFFFFFFUL)) << 32)); 389 } 390 391 _INLINE_ int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap, 392 blk_t block) 393 { 394 return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, 395 block); 396 } 397 398 _INLINE_ int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap, 399 blk_t block) 400 { 401 return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, 402 block); 403 } 404 405 _INLINE_ int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap, 406 blk_t block) 407 { 408 return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, 409 block); 410 } 411 412 _INLINE_ int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, 413 ext2_ino_t inode) 414 { 415 return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, 416 inode); 417 } 418 419 _INLINE_ int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap, 420 ext2_ino_t inode) 421 { 422 return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, 423 inode); 424 } 425 426 _INLINE_ int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap, 427 ext2_ino_t inode) 428 { 429 return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, 430 inode); 431 } 432 433 _INLINE_ void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap, 434 blk_t block) 435 { 436 ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, block); 437 } 438 439 _INLINE_ void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap, 440 blk_t block) 441 { 442 ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, block); 443 } 444 445 _INLINE_ int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap, 446 blk_t block) 447 { 448 return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, 449 block); 450 } 451 452 _INLINE_ void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, 453 ext2_ino_t inode) 454 { 455 ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode); 456 } 457 458 _INLINE_ void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap, 459 ext2_ino_t inode) 460 { 461 ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode); 462 } 463 464 _INLINE_ int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap, 465 ext2_ino_t inode) 466 { 467 return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, 468 inode); 469 } 470 471 _INLINE_ blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap) 472 { 473 return ext2fs_get_generic_bitmap_start((ext2fs_generic_bitmap) bitmap); 474 } 475 476 _INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap) 477 { 478 return ext2fs_get_generic_bitmap_start((ext2fs_generic_bitmap) bitmap); 479 } 480 481 _INLINE_ blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap) 482 { 483 return ext2fs_get_generic_bitmap_end((ext2fs_generic_bitmap) bitmap); 484 } 485 486 _INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap) 487 { 488 return ext2fs_get_generic_bitmap_end((ext2fs_generic_bitmap) bitmap); 489 } 490 491 _INLINE_ int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap, 492 blk_t block, int num) 493 { 494 return ext2fs_test_block_bitmap_range(bitmap, block, num); 495 } 496 497 _INLINE_ void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap, 498 blk_t block, int num) 499 { 500 ext2fs_mark_block_bitmap_range(bitmap, block, num); 501 } 502 503 _INLINE_ void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap, 504 blk_t block, int num) 505 { 506 ext2fs_unmark_block_bitmap_range(bitmap, block, num); 507 } 508 509 /* 64-bit versions */ 510 511 _INLINE_ int ext2fs_mark_block_bitmap2(ext2fs_block_bitmap bitmap, 512 blk64_t block) 513 { 514 return ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap, 515 block); 516 } 517 518 _INLINE_ int ext2fs_unmark_block_bitmap2(ext2fs_block_bitmap bitmap, 519 blk64_t block) 520 { 521 return ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, block); 522 } 523 524 _INLINE_ int ext2fs_test_block_bitmap2(ext2fs_block_bitmap bitmap, 525 blk64_t block) 526 { 527 return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap, 528 block); 529 } 530 531 _INLINE_ int ext2fs_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap, 532 ext2_ino_t inode) 533 { 534 return ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap, 535 inode); 536 } 537 538 _INLINE_ int ext2fs_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap, 539 ext2_ino_t inode) 540 { 541 return ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, 542 inode); 543 } 544 545 _INLINE_ int ext2fs_test_inode_bitmap2(ext2fs_inode_bitmap bitmap, 546 ext2_ino_t inode) 547 { 548 return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap, 549 inode); 550 } 551 552 _INLINE_ void ext2fs_fast_mark_block_bitmap2(ext2fs_block_bitmap bitmap, 553 blk64_t block) 554 { 555 ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap, block); 556 } 557 558 _INLINE_ void ext2fs_fast_unmark_block_bitmap2(ext2fs_block_bitmap bitmap, 559 blk64_t block) 560 { 561 ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, block); 562 } 563 564 _INLINE_ int ext2fs_fast_test_block_bitmap2(ext2fs_block_bitmap bitmap, 565 blk64_t block) 566 { 567 return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap, 568 block); 569 } 570 571 _INLINE_ void ext2fs_fast_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap, 572 ext2_ino_t inode) 573 { 574 ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap, inode); 575 } 576 577 _INLINE_ void ext2fs_fast_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap, 578 ext2_ino_t inode) 579 { 580 ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, inode); 581 } 582 583 _INLINE_ int ext2fs_fast_test_inode_bitmap2(ext2fs_inode_bitmap bitmap, 584 ext2_ino_t inode) 585 { 586 return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap, 587 inode); 588 } 589 590 _INLINE_ errcode_t ext2fs_find_first_zero_block_bitmap2(ext2fs_block_bitmap bitmap, 591 blk64_t start, 592 blk64_t end, 593 blk64_t *out) 594 { 595 __u64 o; 596 errcode_t rv; 597 598 rv = ext2fs_find_first_zero_generic_bmap((ext2fs_generic_bitmap) bitmap, 599 start, end, &o); 600 if (!rv) 601 *out = o; 602 return rv; 603 } 604 605 _INLINE_ errcode_t ext2fs_find_first_zero_inode_bitmap2(ext2fs_inode_bitmap bitmap, 606 ext2_ino_t start, 607 ext2_ino_t end, 608 ext2_ino_t *out) 609 { 610 __u64 o; 611 errcode_t rv; 612 613 rv = ext2fs_find_first_zero_generic_bmap((ext2fs_generic_bitmap) bitmap, 614 start, end, &o); 615 if (!rv) 616 *out = (ext2_ino_t) o; 617 return rv; 618 } 619 620 _INLINE_ errcode_t ext2fs_find_first_set_block_bitmap2(ext2fs_block_bitmap bitmap, 621 blk64_t start, 622 blk64_t end, 623 blk64_t *out) 624 { 625 __u64 o; 626 errcode_t rv; 627 628 rv = ext2fs_find_first_set_generic_bmap((ext2fs_generic_bitmap) bitmap, 629 start, end, &o); 630 if (!rv) 631 *out = o; 632 return rv; 633 } 634 635 _INLINE_ errcode_t ext2fs_find_first_set_inode_bitmap2(ext2fs_inode_bitmap bitmap, 636 ext2_ino_t start, 637 ext2_ino_t end, 638 ext2_ino_t *out) 639 { 640 __u64 o; 641 errcode_t rv; 642 643 rv = ext2fs_find_first_set_generic_bmap((ext2fs_generic_bitmap) bitmap, 644 start, end, &o); 645 if (!rv) 646 *out = (ext2_ino_t) o; 647 return rv; 648 } 649 650 _INLINE_ blk64_t ext2fs_get_block_bitmap_start2(ext2fs_block_bitmap bitmap) 651 { 652 return ext2fs_get_generic_bmap_start((ext2fs_generic_bitmap) bitmap); 653 } 654 655 _INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_start2(ext2fs_inode_bitmap bitmap) 656 { 657 return (ext2_ino_t) ext2fs_get_generic_bmap_start((ext2fs_generic_bitmap) bitmap); 658 } 659 660 _INLINE_ blk64_t ext2fs_get_block_bitmap_end2(ext2fs_block_bitmap bitmap) 661 { 662 return ext2fs_get_generic_bmap_end((ext2fs_generic_bitmap) bitmap); 663 } 664 665 _INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_end2(ext2fs_inode_bitmap bitmap) 666 { 667 return (ext2_ino_t) ext2fs_get_generic_bmap_end((ext2fs_generic_bitmap) bitmap); 668 } 669 670 _INLINE_ int ext2fs_fast_test_block_bitmap_range2(ext2fs_block_bitmap bitmap, 671 blk64_t block, 672 unsigned int num) 673 { 674 return ext2fs_test_block_bitmap_range2(bitmap, block, num); 675 } 676 677 _INLINE_ void ext2fs_fast_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap, 678 blk64_t block, 679 unsigned int num) 680 { 681 ext2fs_mark_block_bitmap_range2(bitmap, block, num); 682 } 683 684 _INLINE_ void ext2fs_fast_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap, 685 blk64_t block, 686 unsigned int num) 687 { 688 ext2fs_unmark_block_bitmap_range2(bitmap, block, num); 689 } 690 691 #undef _INLINE_ 692 #endif 693 694 #ifndef _EXT2_HAVE_ASM_BITOPS_ 695 extern int ext2fs_set_bit(unsigned int nr,void * addr); 696 extern int ext2fs_clear_bit(unsigned int nr, void * addr); 697 extern int ext2fs_test_bit(unsigned int nr, const void * addr); 698 #endif 699 700 extern int ext2fs_set_bit64(__u64 nr,void * addr); 701 extern int ext2fs_clear_bit64(__u64 nr, void * addr); 702 extern int ext2fs_test_bit64(__u64 nr, const void * addr); 703 extern unsigned int ext2fs_bitcount(const void *addr, unsigned int nbytes); 704