Lines Matching full:dir_info
20 struct dir_info *array;
21 struct dir_info *last_lookup;
37 static void e2fsck_put_dir_info(e2fsck_t ctx, struct dir_info *dir);
41 struct dir_info_db *db = ctx->dir_info;
82 ctx->dir_info = db;
98 db->array = (struct dir_info *)
100 * sizeof (struct dir_info),
112 struct dir_info *dir, ent;
120 if (!ctx->dir_info)
122 db = ctx->dir_info;
124 if (ctx->dir_info->count >= ctx->dir_info->size) {
125 old_size = ctx->dir_info->size * sizeof(struct dir_info);
126 ctx->dir_info->size += 10;
127 retval = ext2fs_resize_mem(old_size, ctx->dir_info->size *
128 sizeof(struct dir_info),
129 &ctx->dir_info->array);
131 ctx->dir_info->size -= 10;
150 * need to move the dir_info entries down to make room, since
151 * the dir_info array needs to be sorted by inode number for
154 if (ctx->dir_info->count &&
155 ctx->dir_info->array[ctx->dir_info->count-1].ino >= ino) {
156 for (i = ctx->dir_info->count-1; i > 0; i--)
157 if (ctx->dir_info->array[i-1].ino < ino)
159 dir = &ctx->dir_info->array[i];
161 for (j = ctx->dir_info->count++; j > i; j--)
162 ctx->dir_info->array[j] = ctx->dir_info->array[j-1];
164 dir = &ctx->dir_info->array[ctx->dir_info->count++];
175 static struct dir_info *e2fsck_get_dir_info(e2fsck_t ctx, ext2_ino_t ino)
177 struct dir_info_db *db = ctx->dir_info;
180 static struct dir_info ret_dir_info;
218 high = ctx->dir_info->count-1;
219 if (ino == ctx->dir_info->array[low].ino) {
222 ctx->dir_info->array[low].dotdot,
223 ctx->dir_info->array[low].parent);
225 return &ctx->dir_info->array[low];
227 if (ino == ctx->dir_info->array[high].ino) {
230 ctx->dir_info->array[high].dotdot,
231 ctx->dir_info->array[high].parent);
233 return &ctx->dir_info->array[high];
240 if (ino == ctx->dir_info->array[mid].ino) {
243 ctx->dir_info->array[mid].dotdot,
244 ctx->dir_info->array[mid].parent);
246 return &ctx->dir_info->array[mid];
248 if (ino < ctx->dir_info->array[mid].ino)
256 static void e2fsck_put_dir_info(e2fsck_t ctx, struct dir_info *dir)
258 struct dir_info_db *db = ctx->dir_info;
285 * Free the dir_info structure when it isn't needed any more.
289 if (ctx->dir_info) {
290 if (ctx->dir_info->tdb)
291 tdb_close(ctx->dir_info->tdb);
292 if (ctx->dir_info->tdb_fn) {
293 unlink(ctx->dir_info->tdb_fn);
294 free(ctx->dir_info->tdb_fn);
296 if (ctx->dir_info->array)
297 ext2fs_free_mem(&ctx->dir_info->array);
298 ctx->dir_info->array = 0;
299 ctx->dir_info->size = 0;
300 ctx->dir_info->count = 0;
301 ext2fs_free_mem(&ctx->dir_info);
302 ctx->dir_info = 0;
307 * Return the count of number of directories in the dir_info structure
311 return ctx->dir_info ? ctx->dir_info->count : 0;
317 struct dir_info_db *db = ctx->dir_info;
320 "dir_info iterator");
339 struct dir_info *e2fsck_dir_info_iter(e2fsck_t ctx, struct dir_info_iter *iter)
342 struct dir_info_db *db = ctx->dir_info;
344 static struct dir_info ret_dir_info;
346 if (!ctx->dir_info || !iter)
369 if (iter->i >= ctx->dir_info->count)
373 printf("iter(%d, %d, %d)...", ctx->dir_info->array[iter->i].ino,
374 ctx->dir_info->array[iter->i].dotdot,
375 ctx->dir_info->array[iter->i].parent);
377 ctx->dir_info->last_lookup = ctx->dir_info->array + iter->i++;
378 return(ctx->dir_info->last_lookup);
388 struct dir_info *p;
405 struct dir_info *p;
422 struct dir_info *p;
438 struct dir_info *p;