Opened 6 years ago

Last modified 5 years 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 6 years ago.

Download all attachments as: .zip

Change History (5)

by leorize, 6 years ago

Attachment: ut.c added

comment:1 by leorize, 6 years ago

patch: 01

comment:2 by leorize, 6 years ago

patch: 10

comment:3 by korli, 6 years 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, 5 years ago

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