Lines Matching refs:dblist
63 ext2_dblist dblist = NULL; in make_dblist() local
70 if ((ret_dblist == 0) && fs->dblist && in make_dblist()
71 (fs->dblist->magic == EXT2_ET_MAGIC_DBLIST)) in make_dblist()
74 retval = ext2fs_get_mem(sizeof(struct ext2_struct_dblist), &dblist); in make_dblist()
77 memset(dblist, 0, sizeof(struct ext2_struct_dblist)); in make_dblist()
79 dblist->magic = EXT2_ET_MAGIC_DBLIST; in make_dblist()
80 dblist->fs = fs; in make_dblist()
82 dblist->size = size; in make_dblist()
87 dblist->size = (num_dirs * 2) + 12; in make_dblist()
89 len = (size_t) sizeof(struct ext2_db_entry2) * dblist->size; in make_dblist()
90 dblist->count = count; in make_dblist()
91 retval = ext2fs_get_array(dblist->size, sizeof(struct ext2_db_entry2), in make_dblist()
92 &dblist->list); in make_dblist()
97 memcpy(dblist->list, list, len); in make_dblist()
99 memset(dblist->list, 0, len); in make_dblist()
101 *ret_dblist = dblist; in make_dblist()
103 fs->dblist = dblist; in make_dblist()
106 if (dblist) in make_dblist()
107 ext2fs_free_mem(&dblist); in make_dblist()
116 ext2_dblist dblist; in ext2fs_init_dblist() local
119 retval = make_dblist(fs, 0, 0, 0, &dblist); in ext2fs_init_dblist()
123 dblist->sorted = 1; in ext2fs_init_dblist()
125 *ret_dblist = dblist; in ext2fs_init_dblist()
127 fs->dblist = dblist; in ext2fs_init_dblist()
137 ext2_dblist dblist; in ext2fs_copy_dblist() local
141 &dblist); in ext2fs_copy_dblist()
144 dblist->sorted = src->sorted; in ext2fs_copy_dblist()
145 *dest = dblist; in ext2fs_copy_dblist()
159 errcode_t ext2fs_add_dir_block2(ext2_dblist dblist, ext2_ino_t ino, in ext2fs_add_dir_block2() argument
166 EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); in ext2fs_add_dir_block2()
168 if (dblist->count >= dblist->size) { in ext2fs_add_dir_block2()
169 old_size = dblist->size * sizeof(struct ext2_db_entry2); in ext2fs_add_dir_block2()
170 dblist->size += dblist->size > 200 ? dblist->size / 2 : 100; in ext2fs_add_dir_block2()
171 retval = ext2fs_resize_mem(old_size, (size_t) dblist->size * in ext2fs_add_dir_block2()
173 &dblist->list); in ext2fs_add_dir_block2()
175 dblist->size = old_size / sizeof(struct ext2_db_entry2); in ext2fs_add_dir_block2()
179 new_entry = dblist->list + ( dblist->count++); in ext2fs_add_dir_block2()
184 dblist->sorted = 0; in ext2fs_add_dir_block2()
192 errcode_t ext2fs_set_dir_block2(ext2_dblist dblist, ext2_ino_t ino, in ext2fs_set_dir_block2() argument
197 EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); in ext2fs_set_dir_block2()
199 for (i=0; i < dblist->count; i++) { in ext2fs_set_dir_block2()
200 if ((dblist->list[i].ino != ino) || in ext2fs_set_dir_block2()
201 (dblist->list[i].blockcnt != blockcnt)) in ext2fs_set_dir_block2()
203 dblist->list[i].blk = blk; in ext2fs_set_dir_block2()
204 dblist->sorted = 0; in ext2fs_set_dir_block2()
210 void ext2fs_dblist_sort2(ext2_dblist dblist, in ext2fs_dblist_sort2() argument
216 qsort(dblist->list, (size_t) dblist->count, in ext2fs_dblist_sort2()
218 dblist->sorted = 1; in ext2fs_dblist_sort2()
224 errcode_t ext2fs_dblist_iterate2(ext2_dblist dblist, in ext2fs_dblist_iterate2() argument
233 EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); in ext2fs_dblist_iterate2()
235 if (!dblist->sorted) in ext2fs_dblist_iterate2()
236 ext2fs_dblist_sort2(dblist, 0); in ext2fs_dblist_iterate2()
237 for (i=0; i < dblist->count; i++) { in ext2fs_dblist_iterate2()
238 ret = (*func)(dblist->fs, &dblist->list[i], priv_data); in ext2fs_dblist_iterate2()
261 blk64_t ext2fs_dblist_count2(ext2_dblist dblist) in ext2fs_dblist_count2() argument
263 return dblist->count; in ext2fs_dblist_count2()
266 errcode_t ext2fs_dblist_get_last2(ext2_dblist dblist, in ext2fs_dblist_get_last2() argument
269 EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); in ext2fs_dblist_get_last2()
271 if (dblist->count == 0) in ext2fs_dblist_get_last2()
275 *entry = dblist->list + ( dblist->count-1); in ext2fs_dblist_get_last2()
279 errcode_t ext2fs_dblist_drop_last(ext2_dblist dblist) in ext2fs_dblist_drop_last() argument
281 EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); in ext2fs_dblist_drop_last()
283 if (dblist->count == 0) in ext2fs_dblist_drop_last()
286 dblist->count--; in ext2fs_dblist_drop_last()
297 errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ext2_ino_t ino, blk_t blk, in ext2fs_add_dir_block() argument
300 return ext2fs_add_dir_block2(dblist, ino, blk, blockcnt); in ext2fs_add_dir_block()
306 errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ext2_ino_t ino, blk_t blk, in ext2fs_set_dir_block() argument
309 return ext2fs_set_dir_block2(dblist, ino, blk, blockcnt); in ext2fs_set_dir_block()
312 void ext2fs_dblist_sort(ext2_dblist dblist, in ext2fs_dblist_sort() argument
321 qsort(dblist->list, (size_t) dblist->count, in ext2fs_dblist_sort()
323 dblist->sorted = 1; in ext2fs_dblist_sort()
354 errcode_t ext2fs_dblist_iterate(ext2_dblist dblist, in ext2fs_dblist_iterate() argument
362 EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); in ext2fs_dblist_iterate()
366 return ext2fs_dblist_iterate2(dblist, passthrough_func, &pass); in ext2fs_dblist_iterate()
387 int ext2fs_dblist_count(ext2_dblist dblist) in ext2fs_dblist_count() argument
389 return dblist->count; in ext2fs_dblist_count()
392 errcode_t ext2fs_dblist_get_last(ext2_dblist dblist, in ext2fs_dblist_get_last() argument
398 EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); in ext2fs_dblist_get_last()
400 if (dblist->count == 0) in ext2fs_dblist_get_last()
406 last = dblist->list + dblist->count -1; in ext2fs_dblist_get_last()