From tege@shell.gmplib.org  Thu May 31 14:33:19 2012
Return-Path: <tege@shell.gmplib.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 2EB8F1065672
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 31 May 2012 14:33:19 +0000 (UTC)
	(envelope-from tege@shell.gmplib.org)
Received: from shell.gmplib.org (gmplib-02.nada.kth.se [130.237.222.242])
	by mx1.freebsd.org (Postfix) with ESMTP id DB1CA8FC18
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 31 May 2012 14:33:18 +0000 (UTC)
Received: by shell.gmplib.org (Postfix, from userid 1001)
	id 775491C37C; Thu, 31 May 2012 16:24:08 +0200 (CEST)
Message-Id: <20120531142408.775491C37C@shell.gmplib.org>
Date: Thu, 31 May 2012 16:24:08 +0200 (CEST)
From: Torbjorn Granlund <tege@gmplib.org>
Reply-To: Torbjorn Granlund <tege@gmplib.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: The -nt predicate works inconsistently with zfs, cp -p
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         168499
>Category:       bin
>Synopsis:       The -nt predicate works inconsistently with zfs, cp -p
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 31 14:40:01 UTC 2012
>Closed-Date:    
>Last-Modified:  Thu May 31 20:18:13 UTC 2012
>Originator:     Torbjorn Granlund
>Release:        FreeBSD 8.1-RELEASE-p9 amd64
>Organization:
KTH
>Environment:
System: FreeBSD shell.gmplib.org 8.1-RELEASE-p9 FreeBSD 8.1-RELEASE-p9 #0: Fri May 4 11:19:19 CEST 2012 root@king.gmplib.org:/usr/src/sys/amd64/compile/GENERIC amd64


>Description:

The predicate -nt does not work as expected for files with apparently
identical time stamps.  Whether this happens, seems to depend on the
underlying file system; it does not happen with ufs/ffs (on fbsd 9.0)
but it does happen with zfs (on fbsd 8.1).

It does not happen with bash (4.2.20 installed via ports) with any
[tested] file system.

There is method in the madness, the 2nd file in "cp -p file1 file2" is
considered to be newer.  (I haven't tested this thoroughly.)

Perhaps /bin/cp -p does not copy the full timestamp information, so
this ought to be fixed therein?  (Same goes for touch -r, BTW.)

Or arguably, /bin/test (and its built-in counterpart) should not
consider timestamp information that cannot be preserved by standard
commands.

(This breaks a script that rebuild things when a repository is
touched; the stamp files cannot be compared as they should.)

>How-To-Repeat:
This script should not print anything, but it does:

  #! /bin/sh
  touch foo
  /bin/cp -p foo bar
  [ foo -nt bar ] && echo foo-nt-bar
  [ bar -nt foo ] && echo bar-nt-foo

>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
