RFC: Change mtree nsec handling?

Kostik Belousov kostikbel at gmail.com
Fri Jan 30 13:08:52 PST 2009


On Fri, Jan 30, 2009 at 09:05:22AM -0800, Tim Kientzle wrote:
> Poul-Henning Kamp wrote:
> >In message <49829D49.10306 at 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
Look at the vfs.timestamp_precision sysctl in
sys/kern/vfs_subr.c

> 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
> _______________________________________________
> freebsd-current at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe at freebsd.org"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20090130/bacc3935/attachment.pgp


More information about the freebsd-current mailing list