]> git.ipfire.org Git - thirdparty/e2fsprogs.git/blame - lib/ext2fs/bmap64.h
Merge remote-tracking branch 'josch/libarchive' into josch-libarchive
[thirdparty/e2fsprogs.git] / lib / ext2fs / bmap64.h
CommitLineData
69365c68
TT
1/*
2 * bmap64.h --- 64-bit bitmap structure
3 *
4 * Copyright (C) 2007, 2008 Theodore Ts'o.
5 *
6 * %Begin-Header%
7 * This file may be redistributed under the terms of the GNU Public
8 * License.
9 * %End-Header%
10 */
11
9288e3be
LC
12struct ext2_bmap_statistics {
13 int type;
14 struct timeval created;
15
1625bf42 16#ifdef ENABLE_BMAP_STATS_OPS
9288e3be
LC
17 unsigned long copy_count;
18 unsigned long resize_count;
19 unsigned long mark_count;
20 unsigned long unmark_count;
21 unsigned long test_count;
22 unsigned long mark_ext_count;
23 unsigned long unmark_ext_count;
24 unsigned long test_ext_count;
25 unsigned long set_range_count;
26 unsigned long get_range_count;
27 unsigned long clear_count;
28
29 blk64_t last_marked;
30 blk64_t last_tested;
31 blk64_t mark_back;
32 blk64_t test_back;
33
34 unsigned long mark_seq;
35 unsigned long test_seq;
1625bf42 36#endif /* ENABLE_BMAP_STATS_OPS */
9288e3be
LC
37};
38
39
83d9ffcc 40struct ext2fs_struct_generic_bitmap_64 {
69365c68
TT
41 errcode_t magic;
42 ext2_filsys fs;
43 struct ext2_bitmap_ops *bitmap_ops;
44 int flags;
45 __u64 start, end;
46 __u64 real_end;
94968e74 47 int cluster_bits;
69365c68
TT
48 char *description;
49 void *private;
50 errcode_t base_error_code;
1625bf42 51#ifdef ENABLE_BMAP_STATS
9288e3be
LC
52 struct ext2_bmap_statistics stats;
53#endif
69365c68
TT
54};
55
83d9ffcc
TT
56typedef struct ext2fs_struct_generic_bitmap_64 *ext2fs_generic_bitmap_64;
57
69365c68
TT
58#define EXT2FS_IS_32_BITMAP(bmap) \
59 (((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP) || \
60 ((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP) || \
61 ((bmap)->magic == EXT2_ET_MAGIC_INODE_BITMAP))
62
63#define EXT2FS_IS_64_BITMAP(bmap) \
64 (((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP64) || \
65 ((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP64) || \
66 ((bmap)->magic == EXT2_ET_MAGIC_INODE_BITMAP64))
67
68struct ext2_bitmap_ops {
69 int type;
70 /* Generic bmap operators */
83d9ffcc
TT
71 errcode_t (*new_bmap)(ext2_filsys fs, ext2fs_generic_bitmap_64 bmap);
72 void (*free_bmap)(ext2fs_generic_bitmap_64 bitmap);
73 errcode_t (*copy_bmap)(ext2fs_generic_bitmap_64 src,
74 ext2fs_generic_bitmap_64 dest);
75 errcode_t (*resize_bmap)(ext2fs_generic_bitmap_64 bitmap,
69365c68
TT
76 __u64 new_end,
77 __u64 new_real_end);
78 /* bit set/test operators */
83d9ffcc
TT
79 int (*mark_bmap)(ext2fs_generic_bitmap_64 bitmap, __u64 arg);
80 int (*unmark_bmap)(ext2fs_generic_bitmap_64 bitmap, __u64 arg);
81 int (*test_bmap)(ext2fs_generic_bitmap_64 bitmap, __u64 arg);
82 void (*mark_bmap_extent)(ext2fs_generic_bitmap_64 bitmap, __u64 arg,
69365c68 83 unsigned int num);
83d9ffcc 84 void (*unmark_bmap_extent)(ext2fs_generic_bitmap_64 bitmap, __u64 arg,
69365c68 85 unsigned int num);
83d9ffcc 86 int (*test_clear_bmap_extent)(ext2fs_generic_bitmap_64 bitmap,
69365c68 87 __u64 arg, unsigned int num);
83d9ffcc 88 errcode_t (*set_bmap_range)(ext2fs_generic_bitmap_64 bitmap,
69365c68 89 __u64 start, size_t num, void *in);
83d9ffcc 90 errcode_t (*get_bmap_range)(ext2fs_generic_bitmap_64 bitmap,
69365c68 91 __u64 start, size_t num, void *out);
83d9ffcc
TT
92 void (*clear_bmap)(ext2fs_generic_bitmap_64 bitmap);
93 void (*print_stats)(ext2fs_generic_bitmap_64);
c1a1e7fc
SL
94
95 /* Find the first zero bit between start and end, inclusive.
96 * May be NULL, in which case a generic function is used. */
83d9ffcc 97 errcode_t (*find_first_zero)(ext2fs_generic_bitmap_64 bitmap,
c1a1e7fc 98 __u64 start, __u64 end, __u64 *out);
dff0b6a3
TT
99 /* Find the first set bit between start and end, inclusive.
100 * May be NULL, in which case a generic function is used. */
83d9ffcc 101 errcode_t (*find_first_set)(ext2fs_generic_bitmap_64 bitmap,
dff0b6a3 102 __u64 start, __u64 end, __u64 *out);
69365c68
TT
103};
104
105extern struct ext2_bitmap_ops ext2fs_blkmap64_bitarray;
c1359d91 106extern struct ext2_bitmap_ops ext2fs_blkmap64_rbtree;