From owner-freebsd-bugs@FreeBSD.ORG Tue Jun 1 10:10:03 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F396A1065675 for ; Tue, 1 Jun 2010 10:10:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (unknown [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id BA3DB8FC16 for ; Tue, 1 Jun 2010 10:10:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o51AA27F073943 for ; Tue, 1 Jun 2010 10:10:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o51AA245073935; Tue, 1 Jun 2010 10:10:02 GMT (envelope-from gnats) Resent-Date: Tue, 1 Jun 2010 10:10:02 GMT Resent-Message-Id: <201006011010.o51AA245073935@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Thomas Quinot Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3D16F1065677 for ; Tue, 1 Jun 2010 10:01:18 +0000 (UTC) (envelope-from thomas@cuivre.fr.eu.org) Received: from melamine.cuivre.fr.eu.org (unknown [IPv6:2001:470:1f15:1531:224:e8ff:fe3d:60a5]) by mx1.freebsd.org (Postfix) with ESMTP id 009418FC22 for ; Tue, 1 Jun 2010 10:01:17 +0000 (UTC) Received: by melamine.cuivre.fr.eu.org (Postfix, from userid 1000) id 436725E26; Tue, 1 Jun 2010 12:01:17 +0200 (CEST) Message-Id: <20100601100117.436725E26@melamine.cuivre.fr.eu.org> Date: Tue, 1 Jun 2010 12:01:17 +0200 (CEST) From: Thomas Quinot To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/147275: gzip -c does not save original time stamp X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Thomas Quinot List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Jun 2010 10:10:03 -0000 >Number: 147275 >Category: bin >Synopsis: gzip -c does not save original time stamp >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Jun 01 10:10:02 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Thomas Quinot >Release: FreeBSD 8.0-STABLE amd64 >Organization: >Environment: System: FreeBSD melamine.cuivre.fr.eu.org 8.0-STABLE FreeBSD 8.0-STABLE #0: Sun Mar 28 14:46:11 CEST 2010 thomas@melamine.cuivre.fr.eu.org:/usr/obj/usr/src/sys/GENERIC amd64 >Description: When a file name is provided on the command line, gzip -c does not save its timestamp in the output compressed stream. >How-To-Repeat: cd /tmp touch foo gzip -c foo > foo1.gz gzip foo file foo1.gz foo.gz foo1.gz: gzip compressed data, was "foo", from Unix foo.gz: gzip compressed data, was "foo", from Unix, last modified: Tue Jun 1 11:55:30 2010 >Fix: Index: gzip.c =================================================================== --- gzip.c (révision 208689) +++ gzip.c (copie de travail) @@ -1212,6 +1212,7 @@ { int in; int out; + int rc; off_t size, insize; #ifndef SMALL struct stat isb, osb; @@ -1224,9 +1225,16 @@ return -1; } + /* Stat input file even in stdout (-c) mode so that the + * correct time stamp is inserted in the compressed + * output stream. + */ + + rc = fstat (in, &isb); + if (cflag == 0) { #ifndef SMALL - if (fstat(in, &isb) == 0) { + if (rc == 0) { if (isb.st_nlink > 1 && fflag == 0) { maybe_warnx("%s has %d other link%s -- " "skipping", file, isb.st_nlink - 1, >Release-Note: >Audit-Trail: >Unformatted: