From owner-freebsd-current@FreeBSD.ORG Fri Jan 30 06:48:42 2009 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 47F971065673 for ; Fri, 30 Jan 2009 06:48:42 +0000 (UTC) (envelope-from kientzle@freebsd.org) Received: from kientzle.com (kientzle.com [66.166.149.50]) by mx1.freebsd.org (Postfix) with ESMTP id 73ADE8FC0C for ; Fri, 30 Jan 2009 06:48:41 +0000 (UTC) (envelope-from kientzle@freebsd.org) Received: from [10.123.2.23] (h-66-166-149-52.snvacaid.covad.net [66.166.149.52]) by kientzle.com (8.12.9/8.12.9) with ESMTP id n0U6PFC1038675 for ; Thu, 29 Jan 2009 22:25:26 -0800 (PST) (envelope-from kientzle@freebsd.org) Message-ID: <49829D49.10306@freebsd.org> Date: Thu, 29 Jan 2009 22:25:13 -0800 From: Tim Kientzle User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.12) Gecko/20060422 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "'current@FreeBSD.org'" Content-Type: multipart/mixed; boundary="------------040708020804040103060208" Cc: Subject: RFC: Change mtree nsec handling? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Jan 2009 06:48:42 -0000 This is a multi-part message in MIME format. --------------040708020804040103060208 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit In looking at interoperability between libarchive's mtree support and the mtree(8) program, I found that mtree formats timestamps rather strangely. For example, a timestamp of 1233295862.000001 (1233295682 seconds and 1000 nanoseconds) will be printed like this by mtree: time=1233295862.1000 Unsurprisingly, the mtree parsing works the same way in reverse. Basically, mtree is printing (and reading) the time as whole seconds and nanoseconds separated by a period, which 90% of the time is the same as a decimal floating-point number of seconds, but not the other 10% of the time. This is not documented in mtree.8. I was quite surprised by it. The attached patch changes this to use a more conventional notation (although the patch could use a little more tweaking to handle >9 digits after the decimal point). Any concerns about this? Tim --------------040708020804040103060208 Content-Type: text/x-patch; name="mtree_nsec.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="mtree_nsec.patch" Index: create.c =================================================================== --- create.c (revision 187909) +++ create.c (working copy) @@ -212,7 +212,7 @@ output(indent, &offset, "size=%jd", (intmax_t)p->fts_statp->st_size); if (keys & F_TIME) - output(indent, &offset, "time=%ld.%ld", + output(indent, &offset, "time=%ld.%09ld", (long)p->fts_statp->st_mtimespec.tv_sec, p->fts_statp->st_mtimespec.tv_nsec); if (keys & F_CKSUM && S_ISREG(p->fts_statp->st_mode)) { Index: spec.c =================================================================== --- spec.c (revision 187910) +++ spec.c (working copy) @@ -172,6 +172,7 @@ mode_t *m; int value; char *ep; + int i; for (; (kw = strtok(t, "= \t\n")); t = NULL) { ip->flags |= type = parsekey(kw, &value); @@ -258,6 +259,8 @@ val = ep + 1; ip->st_mtimespec.tv_nsec = strtoul(val, &ep, 10); + for (i = ep - val; i < 9; ++i) + ip->st_mtimespec.tv_nsec *= 10; } else ip->st_mtimespec.tv_nsec = 0; if (*ep) --------------040708020804040103060208--