Opened 10 months ago

Last modified 8 months ago

#14311 new bug

utimes(2) does not set the correct microsecond for modification time

Reported by: leorize Owned by: axeld
Priority: normal Milestone: Unscheduled
Component: File Systems/BFS Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

Attached below is a program that creates a file and set its modification time to 1000 microsecond using utimes(2)

How to run:

$ gcc -o ut ut.c
$ ./ut

Expected output:

Modified second: 0
Modified nanosec: 1000000

Got:

Modified second: 0
Modified nanosec: 786432

Attachments (1)

ut.c (642 bytes) - added by leorize 10 months ago.

Download all attachments as: .zip

Change History (4)

Changed 10 months ago by leorize

Attachment: ut.c added

comment:1 Changed 10 months ago by leorize

Has a Patch: set

comment:2 Changed 10 months ago by leorize

Has a Patch: unset

comment:3 Changed 8 months ago by korli

Component: System/POSIXFile Systems/BFS
Owner: changed from nobody to axeld

It seems to be on BFS? Because write_stat will use: https://github.com/haiku/haiku/blob/master/src/add-ons/kernel/file_systems/bfs/bfs.h#L242 and https://github.com/haiku/haiku/blob/master/src/add-ons/kernel/file_systems/bfs/bfs.h#L287 to calculate the on-disk mtime.

and read_stat: https://github.com/haiku/haiku/blob/master/src/add-ons/kernel/file_systems/bfs/bfs.h#L248

786432 is 48 << 14, (((1000000 + 16383) >> 14) & 0xfff0) is exactly 48.

So it works as badly as designed :)

Note: See TracTickets for help on using tickets.