aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-12-08 21:29:00 -0600
committerRob Landley <rob@landley.net>2016-12-08 21:29:00 -0600
commita975952d885c47aeca013e76194142a47e96d49a (patch)
treedad2f585a2d9a338fdf721f492bff57d4e68e8c4 /lib
parente82d6d14fcc272041e578e8d0a2e342ee65365b3 (diff)
downloadtoybox-a975952d885c47aeca013e76194142a47e96d49a.tar.gz
Add DIRTREE_PROC to skip non-numeric entries and make ps/top etc use it.
Diffstat (limited to 'lib')
-rw-r--r--lib/dirtree.c1
-rw-r--r--lib/lib.h2
2 files changed, 3 insertions, 0 deletions
diff --git a/lib/dirtree.c b/lib/dirtree.c
index 07c1cdc7..f9524a5d 100644
--- a/lib/dirtree.c
+++ b/lib/dirtree.c
@@ -151,6 +151,7 @@ int dirtree_recurse(struct dirtree *node,
// The extra parentheses are to shut the stupid compiler up.
while ((entry = readdir(dir))) {
+ if ((flags&DIRTREE_PROC) && !isdigit(*entry->d_name)) continue;
if (!(new = dirtree_add_node(node, entry->d_name, flags))) continue;
new = dirtree_handle_callback(new, callback);
if (new == DIRTREE_ABORTVAL) break;
diff --git a/lib/lib.h b/lib/lib.h
index 61a1975f..d5a48326 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -73,6 +73,8 @@ void get_optflags(void);
#define DIRTREE_SHUTUP 16
// Breadth first traversal, conserves filehandles at the expense of memory
#define DIRTREE_BREADTH 32
+// skip non-numeric entries
+#define DIRTREE_PROC 64
// Don't look at any more files in this directory.
#define DIRTREE_ABORT 256