aboutsummaryrefslogtreecommitdiff
path: root/lib/dirtree.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2008-11-12 18:01:35 -0600
committerRob Landley <rob@landley.net>2008-11-12 18:01:35 -0600
commitb5d557f0860766bbe89854241e07ff6ec1a2e39a (patch)
tree408ad859b4522ee4db473eb4d458cf12bdaa43e8 /lib/dirtree.c
parentd1aaa0a41308d2ade832db813d42f2f6d3981bd3 (diff)
downloadtoybox-b5d557f0860766bbe89854241e07ff6ec1a2e39a.tar.gz
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.)
Diffstat (limited to 'lib/dirtree.c')
-rw-r--r--lib/dirtree.c22
1 files 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;
}