Mercurial > hg > toybox
diff lib/dirtree.c @ 292:b4077be6c746
Update mdev to work around the newest sysfs api breakage in the 2.6.25 kernel.
(Yeah, I know sysfs hasn't actually got an API, but I like to pretend...)
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 12 May 2008 00:52:27 -0500 |
parents | e9f75ffd3200 |
children | 7259b853cb8b |
line wrap: on
line diff
--- a/lib/dirtree.c Sun May 04 19:44:39 2008 -0500 +++ b/lib/dirtree.c Mon May 12 00:52:27 2008 -0500 @@ -58,6 +58,7 @@ if (!(dir = opendir(path))) perror_msg("No %s", path); else for (;;) { + int norecurse = 0; struct dirent *entry = readdir(dir); if (!entry) { closedir(dir); @@ -74,8 +75,9 @@ *ddt = dirtree_add_node(path); if (!*ddt) continue; (*ddt)->parent = parent; - if (callback) callback(path, *ddt); - if (entry->d_type == DT_DIR) + (*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);