timestamp_truncate() incorrect truncate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux