* timestamp_truncate() incorrect truncate
@ 2020-08-07 9:15 Pavel V. Panteleev
0 siblings, 0 replies; only message in thread
From: Pavel V. Panteleev @ 2020-08-07 9:15 UTC (permalink / raw)
To: linux-fsdevel, viro@zeniv.linux.org.uk >> Al Viro
Hello,
timestamp_truncate() truncates nsec to 0, if sec is 0 for nfs v3. There
is a test:
$ cat ./t.c
#define _GNU_SOURCE
#include <fcntl.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int
main (void)
{
const char *fname = "./delme.log";
int fd;
struct stat sb;
const struct timespec ts[2] = {{0, 199}, {0, 999}};
unlink (fname);
fd = open (fname, O_CREAT | O_TRUNC, 0660);
if (futimens(fd, ts) != 0)
{
perror ("futimens()");
return 1;
}
close (fd);
stat (fname, &sb);
printf ("atim: sec == %ld, nsec == %ld\n",
(long) sb.st_atim.tv_sec,
(long) sb.st_atim.tv_nsec);
printf ("mtim: sec == %ld, nsec == %ld\n",
(long) sb.st_mtim.tv_sec,
(long) sb.st_mtim.tv_nsec);
if (sb.st_atim.tv_sec != ts[0].tv_sec
|| sb.st_atim.tv_nsec != ts[0].tv_nsec
|| sb.st_mtim.tv_sec != ts[1].tv_sec
|| sb.st_mtim.tv_nsec != ts[1].tv_nsec)
return 1;
return 0;
}
(sec + nsec = nsec) is inside of interval, supported by nfs v3. Why nsec
is truncated to 0?
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-08-07 9:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-07 9:15 timestamp_truncate() incorrect truncate Pavel V. Panteleev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.