Lines Matching refs:dir_info
22 struct dir_info *array;
23 struct dir_info *last_lookup;
43 static void e2fsck_put_dir_info(e2fsck_t ctx, struct dir_info *dir);
48 struct dir_info_db *db = ctx->dir_info; in setup_tdb()
101 ctx->dir_info = db; in setup_db()
119 db->array = (struct dir_info *) in setup_db()
121 * sizeof (struct dir_info), in setup_db()
132 struct dir_info *dir, *old_array; in e2fsck_add_dir_info()
140 if (!ctx->dir_info) in e2fsck_add_dir_info()
143 if (ctx->dir_info->count >= ctx->dir_info->size) { in e2fsck_add_dir_info()
144 old_size = ctx->dir_info->size * sizeof(struct dir_info); in e2fsck_add_dir_info()
145 ctx->dir_info->size += 10; in e2fsck_add_dir_info()
146 old_array = ctx->dir_info->array; in e2fsck_add_dir_info()
147 retval = ext2fs_resize_mem(old_size, ctx->dir_info->size * in e2fsck_add_dir_info()
148 sizeof(struct dir_info), in e2fsck_add_dir_info()
149 &ctx->dir_info->array); in e2fsck_add_dir_info()
153 ctx->dir_info->size); in e2fsck_add_dir_info()
155 ctx->dir_info->size -= 10; in e2fsck_add_dir_info()
158 if (old_array != ctx->dir_info->array) in e2fsck_add_dir_info()
159 ctx->dir_info->last_lookup = NULL; in e2fsck_add_dir_info()
163 if (ctx->dir_info->tdb) { in e2fsck_add_dir_info()
164 struct dir_info ent; in e2fsck_add_dir_info()
183 if (ctx->dir_info->count && in e2fsck_add_dir_info()
184 ctx->dir_info->array[ctx->dir_info->count-1].ino >= ino) { in e2fsck_add_dir_info()
185 for (i = ctx->dir_info->count-1; i > 0; i--) in e2fsck_add_dir_info()
186 if (ctx->dir_info->array[i-1].ino < ino) in e2fsck_add_dir_info()
188 dir = &ctx->dir_info->array[i]; in e2fsck_add_dir_info()
190 for (j = ctx->dir_info->count++; j > i; j--) in e2fsck_add_dir_info()
191 ctx->dir_info->array[j] = ctx->dir_info->array[j-1]; in e2fsck_add_dir_info()
193 dir = &ctx->dir_info->array[ctx->dir_info->count++]; in e2fsck_add_dir_info()
204 static struct dir_info *e2fsck_get_dir_info(e2fsck_t ctx, ext2_ino_t ino) in e2fsck_get_dir_info()
206 struct dir_info_db *db = ctx->dir_info; in e2fsck_get_dir_info()
218 static struct dir_info ret_dir_info; in e2fsck_get_dir_info()
249 high = ctx->dir_info->count-1; in e2fsck_get_dir_info()
250 if (ino == ctx->dir_info->array[low].ino) { in e2fsck_get_dir_info()
253 ctx->dir_info->array[low].dotdot, in e2fsck_get_dir_info()
254 ctx->dir_info->array[low].parent); in e2fsck_get_dir_info()
256 return &ctx->dir_info->array[low]; in e2fsck_get_dir_info()
258 if (ino == ctx->dir_info->array[high].ino) { in e2fsck_get_dir_info()
261 ctx->dir_info->array[high].dotdot, in e2fsck_get_dir_info()
262 ctx->dir_info->array[high].parent); in e2fsck_get_dir_info()
264 return &ctx->dir_info->array[high]; in e2fsck_get_dir_info()
271 if (ino == ctx->dir_info->array[mid].ino) { in e2fsck_get_dir_info()
274 ctx->dir_info->array[mid].dotdot, in e2fsck_get_dir_info()
275 ctx->dir_info->array[mid].parent); in e2fsck_get_dir_info()
277 return &ctx->dir_info->array[mid]; in e2fsck_get_dir_info()
279 if (ino < ctx->dir_info->array[mid].ino) in e2fsck_get_dir_info()
288 struct dir_info *dir EXT2FS_NO_TDB_UNUSED) in e2fsck_put_dir_info()
291 struct dir_info_db *db = ctx->dir_info; in e2fsck_put_dir_info()
324 if (ctx->dir_info) { in e2fsck_free_dir_info()
326 if (ctx->dir_info->tdb) in e2fsck_free_dir_info()
327 tdb_close(ctx->dir_info->tdb); in e2fsck_free_dir_info()
328 if (ctx->dir_info->tdb_fn) { in e2fsck_free_dir_info()
329 if (unlink(ctx->dir_info->tdb_fn) < 0) in e2fsck_free_dir_info()
332 free(ctx->dir_info->tdb_fn); in e2fsck_free_dir_info()
335 if (ctx->dir_info->array) in e2fsck_free_dir_info()
336 ext2fs_free_mem(&ctx->dir_info->array); in e2fsck_free_dir_info()
337 ctx->dir_info->array = 0; in e2fsck_free_dir_info()
338 ctx->dir_info->size = 0; in e2fsck_free_dir_info()
339 ctx->dir_info->count = 0; in e2fsck_free_dir_info()
340 ext2fs_free_mem(&ctx->dir_info); in e2fsck_free_dir_info()
341 ctx->dir_info = 0; in e2fsck_free_dir_info()
350 return ctx->dir_info ? ctx->dir_info->count : 0; in e2fsck_get_num_dirinfo()
361 if (ctx->dir_info->tdb) in e2fsck_dir_info_iter_begin()
362 iter->tdb_iter = tdb_firstkey(ctx->dir_info->tdb); in e2fsck_dir_info_iter_begin()
380 struct dir_info *e2fsck_dir_info_iter(e2fsck_t ctx, struct dir_info_iter *iter) in e2fsck_dir_info_iter()
382 if (!ctx->dir_info || !iter) in e2fsck_dir_info_iter()
386 if (ctx->dir_info->tdb) { in e2fsck_dir_info_iter()
387 static struct dir_info ret_dir_info; in e2fsck_dir_info_iter()
394 data = tdb_fetch(ctx->dir_info->tdb, key); in e2fsck_dir_info_iter()
397 tdb_errorstr(ctx->dir_info->tdb)); in e2fsck_dir_info_iter()
404 iter->tdb_iter = tdb_nextkey(ctx->dir_info->tdb, key); in e2fsck_dir_info_iter()
411 if (iter->i >= ctx->dir_info->count) in e2fsck_dir_info_iter()
415 printf("iter(%d, %d, %d)...", ctx->dir_info->array[iter->i].ino, in e2fsck_dir_info_iter()
416 ctx->dir_info->array[iter->i].dotdot, in e2fsck_dir_info_iter()
417 ctx->dir_info->array[iter->i].parent); in e2fsck_dir_info_iter()
419 ctx->dir_info->last_lookup = ctx->dir_info->array + iter->i++; in e2fsck_dir_info_iter()
420 return(ctx->dir_info->last_lookup); in e2fsck_dir_info_iter()
430 struct dir_info *p; in e2fsck_dir_info_set_parent()
447 struct dir_info *p; in e2fsck_dir_info_set_dotdot()
464 struct dir_info *p; in e2fsck_dir_info_get_parent()
480 struct dir_info *p; in e2fsck_dir_info_get_dotdot()