From b5d557f0860766bbe89854241e07ff6ec1a2e39a Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 12 Nov 2008 18:01:35 -0600 Subject: Work around a reiserfs bug. (One line change, switch from looking at broken struct dirent->dt_type to looking at stat() output. The rest are unrelated variable renames.) --- lib/dirtree.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/dirtree.c b/lib/dirtree.c index a695bb36..1993d007 100644 --- a/lib/dirtree.c +++ b/lib/dirtree.c @@ -52,7 +52,7 @@ struct dirtree *dirtree_add_node(char *path) struct dirtree *dirtree_read(char *path, struct dirtree *parent, int (*callback)(char *path, struct dirtree *node)) { - struct dirtree *dt = NULL, **ddt = &dt; + struct dirtree *dtroot = NULL, *this, **ddt = &dtroot; DIR *dir; int len = strlen(path); @@ -72,19 +72,19 @@ struct dirtree *dirtree_read(char *path, struct dirtree *parent, } snprintf(path+len, sizeof(toybuf)-len, "/%s", entry->d_name); - *ddt = dirtree_add_node(path); - if (!*ddt) continue; - (*ddt)->parent = parent; - (*ddt)->depth = parent ? parent->depth + 1 : 1; - if (callback) norecurse = callback(path, *ddt); - if (!norecurse && entry->d_type == DT_DIR) - (*ddt)->child = dirtree_read(path, *ddt, callback); - if (callback) free(*ddt); - else ddt = &((*ddt)->next); + *ddt = this = dirtree_add_node(path); + if (!this) continue; + this->parent = parent; + this->depth = parent ? parent->depth + 1 : 1; + if (callback) norecurse = callback(path, this); + if (!norecurse && S_ISDIR(this->st.st_mode)) + this->child = dirtree_read(path, this, callback); + if (callback) free(this); + else ddt = &(this->next); path[len]=0; } - return dt; + return dtroot; } -- cgit v1.2.3