changeset 7707:3f57a32346a2

* lib/fts.c (fts_load): Don't set sp->fts_dev here, since p->fts_statp may not yet be defined. (fts_read): Instead, set it in the caller, once p->fts_statp is sure to be defined, and corresponds to a top-level directory.
author Jim Meyering <jim@meyering.net>
date Sun, 03 Dec 2006 10:23:10 +0000
parents bae75a7690b4
children 83d73ca5391c
files ChangeLog lib/fts.c
diffstat 2 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-12-03  Jim Meyering  <jim@meyering.net>
+
+	* lib/fts.c (fts_load): Don't set sp->fts_dev here, since
+	p->fts_statp may not yet be defined.
+	(fts_read): Instead, set it in the caller, once p->fts_statp is
+	sure to be defined, and corresponds to a top-level directory.
+
 2006-12-01  Jim Meyering  <jim@meyering.net>
 
 	* modules/savewd (Depends-on): Add fcntl_h to avoid self-test
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -516,7 +516,6 @@
 		p->fts_namelen = len;
 	}
 	p->fts_accpath = p->fts_path = sp->fts_path;
-	sp->fts_dev = p->fts_statp->st_dev;
 }
 
 int
@@ -743,9 +742,15 @@
 			abort ();
 		      }
 		  }
+
 		sp->fts_cur = p;
 		if (p->fts_info == FTS_D)
 		  {
+		    /* Now that P->fts_statp is guaranteed to be valid,
+		       if this is a command-line directory, record its
+		       device number, to be used for FTS_XDEV.  */
+		    if (p->fts_level == FTS_ROOTLEVEL)
+		      sp->fts_dev = p->fts_statp->st_dev;
 		    Dprintf (("  entering: %s\n", p->fts_path));
 		    if (! enter_dir (sp, p))
 		      {