Opened 38 hours ago

Last modified 37 hours ago

#19214 new bug

utimes assigns arbitrary subsecond timestamps

Reported by: bhaible Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: System/POSIX Version: R1/beta5
Keywords: Cc:
Blocked By: #19213 Blocking:
Platform: All

Description

The utimes() function, specified by POSIX https://pubs.opengroup.org/onlinepubs/9799919799/functions/utimes.html, ought to set the access time and modification time of a file to the specified values. The values consist of an entire seconds part (tv_sec) and a subsecond part (tv_usec).

On Haiku (I'm using a July 2024 snapshot) the subsecond part is ignored, and instead an arbitrary value is used. If this arbitrary value was the same for all files, it would be OK. But no, the arbitrary value are different!

This has the effect that files that should have the same modification time suddenly have different modification times. And thus, when I have a Makefile rule that generates one of the files from the other one, this Makefile rule will trigger, although it shouldn't.

*How to reproduce:* Save fu.c (attached).

$ gcc -Wall fu.c
$ ./a.out
$ ls -lrt --full-time dummy*
-rw-r--r-- 1 user root 0 2024-10-30 16:48:30.022020096 +0100 dummy3
-rw-r--r-- 1 user root 0 2024-10-30 16:48:30.022020096 +0100 dummy2
-rw-r--r-- 1 user root 0 2024-10-30 16:48:30.022020096 +0100 dummy1
-rw-r--r-- 1 user root 0 2024-10-30 16:48:30.022020096 +0100 dummy0
-rw-r--r-- 1 user root 0 2024-10-30 16:48:30.022282240 +0100 dummy8
-rw-r--r-- 1 user root 0 2024-10-30 16:48:30.022282240 +0100 dummy7
-rw-r--r-- 1 user root 0 2024-10-30 16:48:30.022282240 +0100 dummy6
-rw-r--r-- 1 user root 0 2024-10-30 16:48:30.022282240 +0100 dummy5
-rw-r--r-- 1 user root 0 2024-10-30 16:48:30.022282240 +0100 dummy4
-rw-r--r-- 1 user root 0 2024-10-30 16:48:30.022544384 +0100 dummy9

You can see that dummy0 and dummy9, for example, have different time stamps.

Attachments (1)

fu.c (533 bytes ) - added by bhaible 38 hours ago.
test case fu.c

Download all attachments as: .zip

Change History (2)

by bhaible, 38 hours ago

Attachment: fu.c added

test case fu.c

comment:1 by waddlesplash, 37 hours ago

Blocked By: 19213 added

This invokes the same syscall as #19213 (_kern_write_stat).

Note: See TracTickets for help on using tickets.