Lines Matching refs:dblist
36 ext2_dblist dblist = NULL; in make_dblist() local
43 if ((ret_dblist == 0) && fs->dblist && in make_dblist()
44 (fs->dblist->magic == EXT2_ET_MAGIC_DBLIST)) in make_dblist()
47 retval = ext2fs_get_mem(sizeof(struct ext2_struct_dblist), &dblist); in make_dblist()
50 memset(dblist, 0, sizeof(struct ext2_struct_dblist)); in make_dblist()
52 dblist->magic = EXT2_ET_MAGIC_DBLIST; in make_dblist()
53 dblist->fs = fs; in make_dblist()
55 dblist->size = size; in make_dblist()
60 dblist->size = (num_dirs * 2) + 12; in make_dblist()
62 len = (size_t) sizeof(struct ext2_db_entry2) * dblist->size; in make_dblist()
63 dblist->count = count; in make_dblist()
64 retval = ext2fs_get_array(dblist->size, sizeof(struct ext2_db_entry2), in make_dblist()
65 &dblist->list); in make_dblist()
70 memcpy(dblist->list, list, len); in make_dblist()
72 memset(dblist->list, 0, len); in make_dblist()
74 *ret_dblist = dblist; in make_dblist()
76 fs->dblist = dblist; in make_dblist()
79 if (dblist) in make_dblist()
80 ext2fs_free_mem(&dblist); in make_dblist()
89 ext2_dblist dblist; in ext2fs_init_dblist() local
92 retval = make_dblist(fs, 0, 0, 0, &dblist); in ext2fs_init_dblist()
96 dblist->sorted = 1; in ext2fs_init_dblist()
98 *ret_dblist = dblist; in ext2fs_init_dblist()
100 fs->dblist = dblist; in ext2fs_init_dblist()
110 ext2_dblist dblist; in ext2fs_copy_dblist() local
114 &dblist); in ext2fs_copy_dblist()
117 dblist->sorted = src->sorted; in ext2fs_copy_dblist()
118 *dest = dblist; in ext2fs_copy_dblist()
132 errcode_t ext2fs_add_dir_block2(ext2_dblist dblist, ext2_ino_t ino, in ext2fs_add_dir_block2() argument
139 EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); in ext2fs_add_dir_block2()
141 if (dblist->count >= dblist->size) { in ext2fs_add_dir_block2()
142 old_size = dblist->size * sizeof(struct ext2_db_entry2); in ext2fs_add_dir_block2()
143 dblist->size += dblist->size > 200 ? dblist->size / 2 : 100; in ext2fs_add_dir_block2()
144 retval = ext2fs_resize_mem(old_size, (size_t) dblist->size * in ext2fs_add_dir_block2()
146 &dblist->list); in ext2fs_add_dir_block2()
148 dblist->size = old_size / sizeof(struct ext2_db_entry2); in ext2fs_add_dir_block2()
152 new_entry = dblist->list + ( dblist->count++); in ext2fs_add_dir_block2()
157 dblist->sorted = 0; in ext2fs_add_dir_block2()
165 errcode_t ext2fs_set_dir_block2(ext2_dblist dblist, ext2_ino_t ino, in ext2fs_set_dir_block2() argument
170 EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); in ext2fs_set_dir_block2()
172 for (i=0; i < dblist->count; i++) { in ext2fs_set_dir_block2()
173 if ((dblist->list[i].ino != ino) || in ext2fs_set_dir_block2()
174 (dblist->list[i].blockcnt != blockcnt)) in ext2fs_set_dir_block2()
176 dblist->list[i].blk = blk; in ext2fs_set_dir_block2()
177 dblist->sorted = 0; in ext2fs_set_dir_block2()
183 void ext2fs_dblist_sort2(ext2_dblist dblist, in ext2fs_dblist_sort2() argument
189 qsort(dblist->list, (size_t) dblist->count, in ext2fs_dblist_sort2()
191 dblist->sorted = 1; in ext2fs_dblist_sort2()
197 errcode_t ext2fs_dblist_iterate3(ext2_dblist dblist, in ext2fs_dblist_iterate3() argument
208 EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); in ext2fs_dblist_iterate3()
211 if (!dblist->sorted) in ext2fs_dblist_iterate3()
212 ext2fs_dblist_sort2(dblist, 0); in ext2fs_dblist_iterate3()
213 if (end > dblist->count) in ext2fs_dblist_iterate3()
214 end = dblist->count; in ext2fs_dblist_iterate3()
216 ret = (*func)(dblist->fs, &dblist->list[i], priv_data); in ext2fs_dblist_iterate3()
223 errcode_t ext2fs_dblist_iterate2(ext2_dblist dblist, in ext2fs_dblist_iterate2() argument
229 return ext2fs_dblist_iterate3(dblist, func, 0, dblist->count, in ext2fs_dblist_iterate2()
249 blk64_t ext2fs_dblist_count2(ext2_dblist dblist) in ext2fs_dblist_count2() argument
251 return dblist->count; in ext2fs_dblist_count2()
254 errcode_t ext2fs_dblist_get_last2(ext2_dblist dblist, in ext2fs_dblist_get_last2() argument
257 EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); in ext2fs_dblist_get_last2()
259 if (dblist->count == 0) in ext2fs_dblist_get_last2()
263 *entry = dblist->list + ( dblist->count-1); in ext2fs_dblist_get_last2()
267 errcode_t ext2fs_dblist_drop_last(ext2_dblist dblist) in ext2fs_dblist_drop_last() argument
269 EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); in ext2fs_dblist_drop_last()
271 if (dblist->count == 0) in ext2fs_dblist_drop_last()
274 dblist->count--; in ext2fs_dblist_drop_last()
285 errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ext2_ino_t ino, blk_t blk, in ext2fs_add_dir_block() argument
288 return ext2fs_add_dir_block2(dblist, ino, blk, blockcnt); in ext2fs_add_dir_block()
294 errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ext2_ino_t ino, blk_t blk, in ext2fs_set_dir_block() argument
297 return ext2fs_set_dir_block2(dblist, ino, blk, blockcnt); in ext2fs_set_dir_block()
300 void ext2fs_dblist_sort(ext2_dblist dblist, in ext2fs_dblist_sort() argument
309 qsort(dblist->list, (size_t) dblist->count, in ext2fs_dblist_sort()
311 dblist->sorted = 1; in ext2fs_dblist_sort()
342 errcode_t ext2fs_dblist_iterate(ext2_dblist dblist, in ext2fs_dblist_iterate() argument
350 EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); in ext2fs_dblist_iterate()
354 return ext2fs_dblist_iterate2(dblist, passthrough_func, &pass); in ext2fs_dblist_iterate()
375 int ext2fs_dblist_count(ext2_dblist dblist) in ext2fs_dblist_count() argument
377 return dblist->count; in ext2fs_dblist_count()
380 errcode_t ext2fs_dblist_get_last(ext2_dblist dblist, in ext2fs_dblist_get_last() argument
386 EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); in ext2fs_dblist_get_last()
388 if (dblist->count == 0) in ext2fs_dblist_get_last()
394 last = dblist->list + dblist->count -1; in ext2fs_dblist_get_last()