If a file disappears after reading directory entries tree(1) treats
this as a fatal error. I think the code should just ignore files which
have disappeared.

Observed when running tree on a directory where temporary files
are constantly created and deleted.
  $ while true; do tree >/dev/null || break; done
in this directory will eventually fail with
  tree: fts_read: No such file or directory

Index: Makefile
===================================================================
RCS file: /cvs/ports/sysutils/tree/Makefile,v
retrieving revision 1.7
diff -u -p -r1.7 Makefile
--- Makefile    23 Jun 2011 22:50:29 -0000      1.7
+++ Makefile    9 Sep 2011 12:54:41 -0000
@@ -3,7 +3,7 @@
 COMMENT=       print ascii formatted tree of a directory structure
 
 DISTNAME=      tree-0.61
-REVISION =     3
+REVISION =     4
 CATEGORIES=    sysutils
 
 HOMEPAGE=      http://spootnik.org/tree/
Index: patches/patch-tree_c
===================================================================
RCS file: /cvs/ports/sysutils/tree/patches/patch-tree_c,v
retrieving revision 1.1
diff -u -p -r1.1 patch-tree_c
--- patches/patch-tree_c        21 Sep 2010 19:17:31 -0000      1.1
+++ patches/patch-tree_c        9 Sep 2011 12:59:08 -0000
@@ -1,6 +1,6 @@
 $OpenBSD: patch-tree_c,v 1.1 2010/09/21 19:17:31 stsp Exp $
 --- tree.c.orig        Wed Jun 21 20:47:54 2006
-+++ tree.c     Mon Sep 20 19:59:40 2010
++++ tree.c     Fri Sep  9 14:59:04 2011
 @@ -139,7 +139,7 @@ format_entry(FTSENT *entry)
  
        if (entry->fts_info == FTS_SL) {
@@ -10,3 +10,14 @@ $OpenBSD: patch-tree_c,v 1.1 2010/09/21 
                        err(1, "readlink: %s", entry->fts_path);
                sz += strlen(buf) + 5;
                if ((str = realloc(str, sz)) == NULL)
+@@ -182,7 +182,9 @@ walk(char *path, int ftsoptions)
+       (void)printf("%s\n", path);
+       for (entry = fts_read(tree); entry != NULL; entry = fts_read(tree)) {
+ 
+-              if (entry->fts_info == FTS_ERR || entry->fts_info == FTS_NS)
++              if (entry->fts_info == FTS_NS)
++                      continue;
++              if (entry->fts_info == FTS_ERR)
+                       errx(1, "fts_read: %s", strerror(entry->fts_errno));
+               
+               padlen =  (depth * 4) + 1;

Reply via email to