bug-gzip
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: file modification time not properly set on Cygwin


From: Jim Meyering
Subject: Re: file modification time not properly set on Cygwin
Date: Fri, 19 Mar 2010 18:11:34 +0100

Denis Excoffier wrote:
> On Mon, Mar 15, 2010 at 07:26:59PM -0600, Eric Blake wrote:
>>> On 03/15/2010 09:35 AM, Denis Excoffier wrote:
>>> >
>>> > Hello,
>>> >
>>> > It seems that on Cygwin, the `file modification time in Unix
> format' of
>>> > the output format is not set properly.
>>>
>>> Please report this to the cygwin list; it is quite likely that the
> bug
>>> lies either in cygwin1.dll or in the particular port of gzip to
> cygwin,
>>> rather than upstream.
>
> This has been reported to the cygwin list (see
> http://cygwin.com/ml/cygwin/2010-03/msg00549.html). In her
> answer, Corinna Vinschen states (implicitly) that you cannot assume
> that the st_mtime of a pipe is not "artificially" forged.
>
> If i understand correctly the file `gzip.c' lines 625 to 634
> (gzip-1.4.tar.gz), a call to `time_t time()' has to be added around.

Thanks for the report.
Here's a proposed patch.
As you know, it should make no difference on Linux
(other than the additional syscall).
Can you confirm that it solves the problem on Cygwin?

>From 8415ef4cebf510f279c7e1b9f641ac8d8abfe0ed Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 19 Mar 2010 18:09:20 +0100
Subject: [PATCH] * gzip.c: Include "timespec.h".

(treat_stdin): Use st_mtime only from a regular file.
This matters at least on Cygwin 1.7.1-1, for which stdin gets
the mtime of /dev/null, rather than the gzip-documented-for-pipes
"current time".  Reported by Denis Excoffier.
---
 THANKS |    1 +
 gzip.c |    8 +++++++-
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/THANKS b/THANKS
index b0833e5..a69f832 100644
--- a/THANKS
+++ b/THANKS
@@ -74,6 +74,7 @@ Paul Eggert             address@hidden
 Enami                   address@hidden
 Kristoffer Eriksson     address@hidden
 Daniel Eriksson         address@hidden
+Denis Excoffier         address@hidden
 Rik Faith               address@hidden
 Larry Fahnoe            address@hidden
 Cristian Ferretti       address@hidden
diff --git a/gzip.c b/gzip.c
index d1105e5..41322ec 100644
--- a/gzip.c
+++ b/gzip.c
@@ -67,6 +67,7 @@ static char const *const license_msg[] = {
 #include "gzip.h"
 #include "lzw.h"
 #include "revision.h"
+#include "timespec.h"

 #include "fcntl-safer.h"
 #include "getopt.h"
@@ -648,7 +649,12 @@ local void treat_stdin()
     ifile_size = S_ISREG (istat.st_mode) ? istat.st_size : -1;
     time_stamp.tv_nsec = -1;
     if (!no_time || list)
-      time_stamp = get_stat_mtime (&istat);
+      {
+        if (S_ISREG (istat.st_mode))
+          time_stamp = get_stat_mtime (&istat);
+        else
+          gettime (&time_stamp);
+      }

     clear_bufs(); /* clear input and output buffers */
     to_stdout = 1;
--
1.7.0.2.455.g91132




reply via email to

[Prev in Thread] Current Thread [Next in Thread]