* %End-Header%
*/
+#include "config.h"
#include <stdio.h>
#include <string.h>
#if HAVE_UNISTD_H
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
+#if HAVE_LINUX_TYPES_H
+#include <linux/types.h>
+#endif
#include "ext2_fs.h"
#include "ext2fsP.h"
struct bmap_rb_extent *wcursor;
struct bmap_rb_extent *rcursor;
struct bmap_rb_extent *rcursor_next;
-#ifdef BMAP_STATS_OPS
+#ifdef ENABLE_BMAP_STATS_OPS
__u64 mark_hit;
__u64 test_hit;
#endif
retval = ext2fs_get_mem(sizeof (struct bmap_rb_extent),
&new_ext);
- if (retval) {
- perror("ext2fs_get_mem");
- exit(1);
- }
+ if (retval)
+ abort();
new_ext->start = start;
new_ext->count = count;
bp->rcursor_next = NULL;
bp->wcursor = NULL;
-#ifdef BMAP_STATS_OPS
+#ifdef ENABLE_BMAP_STATS_OPS
bp->test_hit = 0;
bp->mark_hit = 0;
#endif
goto search_tree;
if (bit >= rcursor->start && bit < rcursor->start + rcursor->count) {
-#ifdef BMAP_STATS_OPS
+#ifdef ENABLE_BMAP_STATS_OPS
bp->test_hit++;
#endif
return 1;
if (ext) {
if (start >= ext->start &&
start <= (ext->start + ext->count)) {
-#ifdef BMAP_STATS_OPS
+#ifdef ENABLE_BMAP_STATS_OPS
bp->mark_hit++;
#endif
goto got_extent;
__u64 new_start, new_count;
int retval = 0;
- if (EXT2FS_RB_EMPTY_ROOT(root))
+ if (ext2fs_rb_empty_root(root))
return 0;
while (*n) {
retval = 1;
continue;
} else {
- /* modify the last extent in reigon to be removed */
+ /* modify the last extent in region to be removed */
ext->count -= ((start + count) - ext->start);
ext->start = start + count;
retval = 1;
n = &bp->root.rb_node;
start -= bitmap->start;
- if ((len == 0) || EXT2FS_RB_EMPTY_ROOT(&bp->root))
+ if (len == 0 || ext2fs_rb_empty_root(&bp->root))
return 1;
/*
struct rb_node *parent = NULL, *next, **n;
struct ext2fs_rb_private *bp;
struct bmap_rb_extent *ext;
- int count;
- __u64 pos;
+ __u64 count, pos;
bp = (struct ext2fs_rb_private *) bitmap->private;
n = &bp->root.rb_node;
start -= bitmap->start;
- if (EXT2FS_RB_EMPTY_ROOT(&bp->root))
+ if (ext2fs_rb_empty_root(&bp->root))
return 0;
while (*n) {
if (pos >= start + num)
break;
if (pos < start) {
- count -= start - pos;
- if (count < 0)
+ if (pos + count < start)
continue;
+ count -= start - pos;
pos = start;
}
if (pos + count > start + num)
if (start > end)
return EINVAL;
- if (EXT2FS_RB_EMPTY_ROOT(&bp->root))
+ if (ext2fs_rb_empty_root(&bp->root))
return ENOENT;
while (*n) {
if (start > end)
return EINVAL;
- if (EXT2FS_RB_EMPTY_ROOT(&bp->root))
+ if (ext2fs_rb_empty_root(&bp->root))
return ENOENT;
while (*n) {
return ENOENT;
}
-#ifdef BMAP_STATS
+#ifdef ENABLE_BMAP_STATS
static void rb_print_stats(ext2fs_generic_bitmap bitmap)
{
struct ext2fs_rb_private *bp;
__u64 min_size = ULONG_MAX;
__u64 size = 0, avg_size = 0;
double eff;
-#ifdef BMAP_STATS_OPS
+#ifdef ENABLE_BMAP_STATS_OPS
__u64 mark_all, test_all;
double m_hit = 0.0, t_hit = 0.0;
#endif
min_size = 0;
eff = (double)((count * sizeof(struct bmap_rb_extent)) << 3) /
(bitmap->real_end - bitmap->start);
-#ifdef BMAP_STATS_OPS
+#ifdef ENABLE_BMAP_STATS_OPS
mark_all = bitmap->stats.mark_count + bitmap->stats.mark_ext_count;
test_all = bitmap->stats.test_count + bitmap->stats.test_ext_count;
if (mark_all)
eff);
}
#else
-static void rb_print_stats(ext2fs_generic_bitmap bitmap){}
+static void rb_print_stats(ext2fs_generic_bitmap bitmap EXT2FS_ATTR((unused)))
+{
+}
#endif
struct ext2_bitmap_ops ext2fs_blkmap64_rbtree = {