[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: test-stat-time failure on FreeBSD 6
From: |
Paul Eggert |
Subject: |
Re: test-stat-time failure on FreeBSD 6 |
Date: |
Tue, 03 Apr 2007 13:23:07 -0700 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
"James Youngman" <address@hidden> writes:
> Sorry. For some reason the sanity check on the value of
> st_birthtim.tv_sec ended up in the wrong arm of an #if and was
> therefore not performed.
Thanks, I installed this slightly-different patch.
2007-04-03 James Youngman <address@hidden>
and Paul Eggert <address@hidden>
* lib/stat-time.h (get_stat_birthtime): Check for zero-valued
birthtime on all systems that have birthtime, not just those which
use st_birthtimensec rather than st_birthtim. Putting zero in
st_birthtim.tv_sec is how (for example) FreeBSD/x86 6.1 indicates
that the birth time is not available for files on an NFS mount.
--- lib/stat-time.h 27 Mar 2007 20:03:47 -0000 1.7
+++ lib/stat-time.h 3 Apr 2007 20:18:58 -0000
@@ -147,22 +147,12 @@ get_stat_birthtime (struct stat const *s
{
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 @@ get_stat_birthtime (struct stat const *s
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;
}