changeset 8621:71d64e4302fa

* lib/stat-time.h: (get_stat_birthtime): Check for zero-valued birthtime on all systems, not just those which use st_birthtimensec rather than st_birthtim. Putting zero in st_bithtim.tv_sec is how (for example) FreeBSD/x86 6.1 indicates that the birth time is not available for files on an NFS mount.
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 03 Apr 2007 20:19:02 +0000
parents 6b79d341a41b
children fa9ca3610730
files ChangeLog lib/stat-time.h
diffstat 2 files changed, 24 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-04-03  James Youngman  <jay@gnu.org>
+
+	* lib/stat-time.h: (get_stat_birthtime): Check for zero-valued
+	birthtime on all systems, not just those which use
+	st_birthtimensec rather than st_birthtim.  Putting zero in
+	st_bithtim.tv_sec is how (for example) FreeBSD/x86 6.1
+	indicates that the birth time is not available for files on
+	an NFS mount.
+
 2007-04-03  Simon Josefsson  <simon@josefsson.org>
 
 	* modules/memxor: Move back from crypto/, suggested by Bruno.
--- a/lib/stat-time.h
+++ b/lib/stat-time.h
@@ -147,22 +147,12 @@
 {
   struct timespec t;
 
-#if defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
-  || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC
+#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
+     || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC)
   t = STAT_TIMESPEC (st, st_birthtim);
 #elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
   t.tv_sec = st->st_birthtime;
   t.tv_nsec = st->st_birthtimensec;
-
-  /* NetBSD sometimes signals the absence of knowledge by using zero.
-     Attempt to work around this bug.  This sometimes reports failure
-     even for valid time stamps.  Also, sometimes NetBSD returns junk
-     in the birth time fields; work around this bug if it it is
-     detected.  There's no need to detect negative tv_nsec junk as
-     negative tv_nsec already indicates an error.  */
-  if (t.tv_sec == 0 || 1000000000 <= t.tv_nsec)
-    t.tv_nsec = -1;
-
 #elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
   /* Woe32 native platforms (but not Cygwin) put the "file creation
      time" in st_ctime (!).  See
@@ -175,6 +165,19 @@
   t.tv_nsec = -1;
 #endif
 
+#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
+     || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC \
+     || defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC)
+  /* FreeBSD and NetBSD sometimes signal the absence of knowledge by
+     using zero.  Attempt to work around this problem.  Alas, this can
+     report failure even for valid time stamps.  Also, NetBSD
+     sometimes returns junk in the birth time fields; work around this
+     bug if it it is detected.  There's no need to detect negative
+     tv_nsec junk as negative tv_nsec already indicates an error.  */
+  if (t.tv_sec == 0 || 1000000000 <= t.tv_nsec)
+    t.tv_nsec = -1;
+#endif
+
   return t;
 }