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