Opened 40 hours ago

Closed 39 hours ago

#19212 closed bug (duplicate)

futimens 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 futimens() function, specified by POSIX https://pubs.opengroup.org/onlinepubs/9799919799/functions/futimens.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_nsec).

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.018087936 +0100 dummy1
-rw-r--r-- 1 user root         0 2024-10-30 16:48:30.018087936 +0100 dummy0
-rw-r--r-- 1 user root         0 2024-10-30 16:48:30.018350080 +0100 dummy6
-rw-r--r-- 1 user root         0 2024-10-30 16:48:30.018350080 +0100 dummy5
-rw-r--r-- 1 user root         0 2024-10-30 16:48:30.018350080 +0100 dummy4
-rw-r--r-- 1 user root         0 2024-10-30 16:48:30.018350080 +0100 dummy3
-rw-r--r-- 1 user root         0 2024-10-30 16:48:30.018350080 +0100 dummy2
-rw-r--r-- 1 user root         0 2024-10-30 16:48:30.018612224 +0100 dummy9
-rw-r--r-- 1 user root         0 2024-10-30 16:48:30.018612224 +0100 dummy8
-rw-r--r-- 1 user root         0 2024-10-30 16:48:30.018612224 +0100 dummy7

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

Attachments (1)

fu.c (515 bytes ) - added by bhaible 40 hours ago.
test case fu.c

Download all attachments as: .zip

Change History (2)

by bhaible, 40 hours ago

Attachment: fu.c added

test case fu.c

comment:1 by waddlesplash, 39 hours ago

Blocked By: 19213 added
Resolution: duplicate
Status: newclosed

The futimens implementation invokes utimensat.

Note: See TracTickets for help on using tickets.