Mike Frysinger | 1fd98e0 | 2005-05-09 22:10:42 +0000 | [diff] [blame] | 1 | /* |
| 2 | * bitops.h --- Bitmap frobbing code. The byte swapping routines are |
Tim Riker | c1ef7bd | 2006-01-25 00:08:53 +0000 | [diff] [blame] | 3 | * also included here. |
| 4 | * |
Mike Frysinger | 1fd98e0 | 2005-05-09 22:10:42 +0000 | [diff] [blame] | 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 Public |
| 9 | * License. |
| 10 | * %End-Header% |
Tim Riker | c1ef7bd | 2006-01-25 00:08:53 +0000 | [diff] [blame] | 11 | * |
Mike Frysinger | 1fd98e0 | 2005-05-09 22:10:42 +0000 | [diff] [blame] | 12 | * i386 bitops operations taken from <asm/bitops.h>, Copyright 1992, |
| 13 | * Linus Torvalds. |
| 14 | */ |
| 15 | |
Mike Frysinger | 179f417 | 2006-03-18 04:13:32 +0000 | [diff] [blame] | 16 | #include <string.h> |
Mike Frysinger | f98f5e3 | 2005-06-11 00:11:46 +0000 | [diff] [blame] | 17 | #include <strings.h> |
Mike Frysinger | 1fd98e0 | 2005-05-09 22:10:42 +0000 | [diff] [blame] | 18 | |
Mike Frysinger | 874af85 | 2006-03-08 07:03:27 +0000 | [diff] [blame] | 19 | extern int ext2fs_set_bit(unsigned int nr,void * addr); |
| 20 | extern int ext2fs_clear_bit(unsigned int nr, void * addr); |
| 21 | extern int ext2fs_test_bit(unsigned int nr, const void * addr); |
Mike Frysinger | 1fd98e0 | 2005-05-09 22:10:42 +0000 | [diff] [blame] | 22 | extern __u16 ext2fs_swab16(__u16 val); |
| 23 | extern __u32 ext2fs_swab32(__u32 val); |
| 24 | |
| 25 | #ifdef WORDS_BIGENDIAN |
| 26 | #define ext2fs_cpu_to_le32(x) ext2fs_swab32((x)) |
| 27 | #define ext2fs_le32_to_cpu(x) ext2fs_swab32((x)) |
| 28 | #define ext2fs_cpu_to_le16(x) ext2fs_swab16((x)) |
| 29 | #define ext2fs_le16_to_cpu(x) ext2fs_swab16((x)) |
| 30 | #define ext2fs_cpu_to_be32(x) ((__u32)(x)) |
| 31 | #define ext2fs_be32_to_cpu(x) ((__u32)(x)) |
| 32 | #define ext2fs_cpu_to_be16(x) ((__u16)(x)) |
| 33 | #define ext2fs_be16_to_cpu(x) ((__u16)(x)) |
| 34 | #else |
| 35 | #define ext2fs_cpu_to_le32(x) ((__u32)(x)) |
| 36 | #define ext2fs_le32_to_cpu(x) ((__u32)(x)) |
| 37 | #define ext2fs_cpu_to_le16(x) ((__u16)(x)) |
| 38 | #define ext2fs_le16_to_cpu(x) ((__u16)(x)) |
| 39 | #define ext2fs_cpu_to_be32(x) ext2fs_swab32((x)) |
| 40 | #define ext2fs_be32_to_cpu(x) ext2fs_swab32((x)) |
| 41 | #define ext2fs_cpu_to_be16(x) ext2fs_swab16((x)) |
| 42 | #define ext2fs_be16_to_cpu(x) ext2fs_swab16((x)) |
| 43 | #endif |
| 44 | |
| 45 | /* |
| 46 | * EXT2FS bitmap manipulation routines. |
| 47 | */ |
| 48 | |
| 49 | /* Support for sending warning messages from the inline subroutines */ |
| 50 | extern const char *ext2fs_block_string; |
| 51 | extern const char *ext2fs_inode_string; |
| 52 | extern const char *ext2fs_mark_string; |
| 53 | extern const char *ext2fs_unmark_string; |
| 54 | extern const char *ext2fs_test_string; |
| 55 | extern void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg, |
| 56 | const char *description); |
| 57 | extern void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap, |
| 58 | int code, unsigned long arg); |
| 59 | |
| 60 | extern int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block); |
| 61 | extern int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap, |
| 62 | blk_t block); |
| 63 | extern int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block); |
| 64 | |
| 65 | extern int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode); |
| 66 | extern int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap, |
| 67 | ext2_ino_t inode); |
| 68 | extern int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode); |
| 69 | |
| 70 | extern void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap, |
| 71 | blk_t block); |
| 72 | extern void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap, |
| 73 | blk_t block); |
| 74 | extern int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap, |
| 75 | blk_t block); |
| 76 | |
| 77 | extern void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, |
| 78 | ext2_ino_t inode); |
| 79 | extern void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap, |
| 80 | ext2_ino_t inode); |
| 81 | extern int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap, |
| 82 | ext2_ino_t inode); |
| 83 | extern blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap); |
| 84 | extern ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap); |
| 85 | extern blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap); |
| 86 | extern ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap); |
| 87 | |
| 88 | extern void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap, |
| 89 | blk_t block, int num); |
| 90 | extern void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap, |
| 91 | blk_t block, int num); |
| 92 | extern int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap, |
| 93 | blk_t block, int num); |
| 94 | extern void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap, |
| 95 | blk_t block, int num); |
| 96 | extern void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap, |
| 97 | blk_t block, int num); |
| 98 | extern int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap, |
| 99 | blk_t block, int num); |
| 100 | extern void ext2fs_set_bitmap_padding(ext2fs_generic_bitmap map); |
| 101 | |
| 102 | /* These two routines moved to gen_bitmap.c */ |
| 103 | extern int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap, |
| 104 | __u32 bitno); |
| 105 | extern int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap, |
| 106 | blk_t bitno); |