Write timestamps with exactly 9 digits after the period.

This ensures that the value written is both compatible with
older mtree versions (which expect the value after the period
to be an integer count of nanoseconds after the whole second)
and is a correct floating-point value.

Leave the parsing code unchanged so it will continue to read
older files.
This commit is contained in:
Tim Kientzle 2009-01-31 05:17:28 +00:00
parent 351c4745f1
commit 9feaf24750
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=187940
4 changed files with 9 additions and 3 deletions

View File

@ -212,7 +212,7 @@ statf(int indent, FTSENT *p)
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)) {

View File

@ -200,7 +200,9 @@ The size, in bytes, of the file.
.It Cm link
The file the symbolic link is expected to reference.
.It Cm time
The last modification time of the file.
The last modification time of the file, in seconds and nanoseconds.
The value should include a period character and exactly nine digits
after the period.
.It Cm type
The type of the file; may be set to any one of the following:
.Pp

View File

@ -233,7 +233,9 @@ The size, in bytes, of the file.
.It Cm link
The file the symbolic link is expected to reference.
.It Cm time
The last modification time of the file.
The last modification time of the file, in seconds and nanoseconds.
The value should include a period character and exactly nine digits
after the period.
.It Cm type
The type of the file; may be set to any one of the following:
.Pp

View File

@ -255,6 +255,8 @@ set(char *t, NODE *ip)
case F_TIME:
ip->st_mtimespec.tv_sec = strtoul(val, &ep, 10);
if (*ep == '.') {
/* Note: we require exactly nine
* digits after the decimal point. */
val = ep + 1;
ip->st_mtimespec.tv_nsec
= strtoul(val, &ep, 10);