Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Jan 2009 09:05:22 -0800
From:      Tim Kientzle <kientzle@freebsd.org>
To:        Poul-Henning Kamp <phk@phk.freebsd.dk>
Cc:        "'current@FreeBSD.org'" <current@freebsd.org>
Subject:   Re: RFC: Change mtree nsec handling?
Message-ID:  <49833352.3010208@freebsd.org>
In-Reply-To: <30968.1233310214@critter.freebsd.dk>
References:  <30968.1233310214@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
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....  <shrug>

Tim



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?49833352.3010208>