From owner-freebsd-current@FreeBSD.ORG Fri Jan 30 17:05:28 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 7301F106567D for ; Fri, 30 Jan 2009 17:05:28 +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 47F6C8FC29 for ; Fri, 30 Jan 2009 17:05:28 +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 n0UH5OC1041808; Fri, 30 Jan 2009 09:05:27 -0800 (PST) (envelope-from kientzle@freebsd.org) Message-ID: <49833352.3010208@freebsd.org> Date: Fri, 30 Jan 2009 09:05:22 -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: Poul-Henning Kamp References: <30968.1233310214@critter.freebsd.dk> In-Reply-To: <30968.1233310214@critter.freebsd.dk> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Cc: "'current@FreeBSD.org'" Subject: Re: 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 17:05:28 -0000 Poul-Henning Kamp wrote: > In message <49829D49.10306@freebsd.org>, Tim Kientzle writes: > >>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. > >>@@ -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; > > > Why is this bit needed ? > This is the part that converts 1233295862.000001 into 1000 nanoseconds (instead of 1 nanosecond). Two reasons: 1) Documentation. It's much easier to document "decimal seconds" than "period followed nine digits representing the number of nanoseconds past the whole second." 2) Interoperability. I originally noticed this testing other mtree-producing code against our mtree implementation. For example, since FreeBSD filesystems never (?) store higher resolution than microseconds, there's really no reason to write more than 6 digits after the decimal point. It seems a tad naive to assume that everyone will always write 9 digits. I can leave this out for a cycle if there's real concern. Fractional seconds occur so rarely on FreeBSD systems (to my knowledge, the kernel never spontaneously generates them so they can only be created by tools like touch that explicitly call utimes()) that I didn't think this would affect any real applications. But if I'm wrong.... Tim