Lines Matching defs:extent
2 * extent.c --- ext2 extent abstraction
35 * Create an extent table
39 ext2_extent extent;
42 retval = ext2fs_get_mem(sizeof(struct _ext2_extent), &extent);
45 memset(extent, 0, sizeof(struct _ext2_extent));
47 extent->size = size ? size : 50;
48 extent->cursor = 0;
49 extent->num = 0;
50 extent->sorted = 1;
53 extent->size, &extent->list);
55 ext2fs_free_mem(&extent);
58 memset(extent->list, 0,
59 sizeof(struct ext2_extent_entry) * extent->size);
60 *ret_extent = extent;
65 * Free an extent table
67 void ext2fs_free_extent_table(ext2_extent extent)
69 if (extent->list)
70 ext2fs_free_mem(&extent->list);
71 extent->list = 0;
72 extent->size = 0;
73 extent->num = 0;
74 ext2fs_free_mem(&extent);
78 * Add an entry to the extent table
80 errcode_t ext2fs_add_extent_entry(ext2_extent extent, __u64 old_loc, __u64 new_loc)
87 if (extent->num >= extent->size) {
88 newsize = extent->size + 100;
90 extent->size,
92 newsize, &extent->list);
95 extent->size = newsize;
97 curr = extent->num;
98 ent = extent->list + curr;
102 * extent
114 extent->sorted = 0;
120 extent->num++;
142 __u64 ext2fs_extent_translate(ext2_extent extent, __u64 old_loc)
148 if (!extent->sorted) {
149 qsort(extent->list, extent->num,
151 extent->sorted = 1;
154 high = extent->num-1;
163 lowval = extent->list[low].old_loc;
164 highval = extent->list[high].old_loc;
181 if ((old_loc >= extent->list[mid].old_loc) &&
182 (old_loc < extent->list[mid].old_loc + extent->list[mid].size))
183 return (extent->list[mid].new_loc +
184 (old_loc - extent->list[mid].old_loc));
185 if (old_loc < extent->list[mid].old_loc)
196 void ext2fs_extent_dump(ext2_extent extent, FILE *out)
201 fputs(_("# Extent dump:\n"), out);
203 extent->num, extent->size, extent->cursor, extent->sorted);
204 for (i=0, ent=extent->list; i < extent->num; i++, ent++) {
211 * Iterate over the contents of the extent table
213 errcode_t ext2fs_iterate_extent(ext2_extent extent, __u64 *old_loc,
219 extent->cursor = 0;
223 if (extent->cursor >= extent->num) {
230 ent = extent->list + extent->cursor++;