From 720fc26d33352407715cb286a4edc23d15906d5f Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 4 Feb 2007 19:14:58 -0500 Subject: Add parent pointer to dirtree, more work on mke2fs (populate dirtree, count index blocks). --- lib/lib.c | 5 +++-- lib/lib.h | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/lib.c b/lib/lib.c index a2f1708b..f1d1ce1f 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -534,7 +534,7 @@ struct dirtree *read_dirtree_node(char *path) // Given a directory (in a writeable PATH_MAX buffer), recursively read in a // directory tree. -struct dirtree *read_dirtree(char *path) +struct dirtree *read_dirtree(char *path, struct dirtree *parent) { struct dirtree *dt = NULL, **ddt = &dt; DIR *dir; @@ -554,7 +554,8 @@ struct dirtree *read_dirtree(char *path) snprintf(path+len, sizeof(toybuf)-len, "/%s", entry->d_name); *ddt = read_dirtree_node(path); - if (entry->d_type == DT_DIR) (*ddt)->child = read_dirtree(path); + (*ddt)->parent = parent; + if (entry->d_type == DT_DIR) (*ddt)->child = read_dirtree(path, *ddt); ddt = &((*ddt)->next); path[len]=0; } diff --git a/lib/lib.h b/lib/lib.h index d3c937ca..07cc9cd8 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -22,8 +22,7 @@ struct arg_list { }; struct dirtree { - struct dirtree *next; - struct dirtree *child; + struct dirtree *next, *child, *parent; struct stat st; char name[]; }; @@ -68,7 +67,7 @@ char *utoa(unsigned n); char *itoa(int n); off_t fdlength(int fd); struct dirtree *read_dirtree_node(char *path); -struct dirtree *read_dirtree(char *path); +struct dirtree *read_dirtree(char *path, struct dirtree *parent); // getmountlist.c struct mtab_list { -- cgit v1.2.3