Opened 2 years ago

Last modified 3 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: nielx
Blocked By: Blocking:
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 2 years ago.

Download all attachments as: .zip

Change History (5)

by leorize, 2 years ago

Attachment: ut.c added

comment:1 by leorize, 2 years ago

patch: 01

comment:2 by leorize, 2 years ago

patch: 10

comment:3 by korli, 22 months ago

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 :)

comment:4 by nielx, 3 months ago

Cc: nielx added
Note: See TracTickets for help on using tickets.