truncate and open(O_TRUNC) times.

Chris Johns chrisj at rtems.org
Sun Jul 28 22:31:58 UTC 2013


Hello,

In the RTEMS project we have some test code that appears to fail on 
FreeBSD. You can find a stripped down version at 
http://www.rtems.org/ftp/pub/rtems/people/chrisj/fstimes/truncate-time-test.c

The code does ..

   fd = open (file01, O_CREAT | O_WRONLY, mode);
   n = write (fd, databuf, len);
   assert (n == len);
   status = close (fd);
   assert (status == 0);

   sleep(2);

   status = truncate (file01, len);
   assert (status == 0);

The length does not change and given the file does not change our 
interpretation of the truncate call is the times should not change.

In the case of ..

   fd = open (file03, O_CREAT | O_WRONLY, mode);
   status = close (fd);
   assert (status == 0);

   sleep(2);

   fd = open (file03, O_TRUNC | O_WRONLY, mode);
   status = close (fd);
   assert (status == 0);

the times do change as expected.

Chris


More information about the freebsd-standards mailing list