Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#7120 closed bug (fixed)

Tracker and Terminal show the wrong file dates on NTFS volume

Reported by: Disreali Owned by: 3dEyes
Priority: normal Milestone: R1
Component: File Systems/NTFS Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

Experienced on 40230-2h, but it has been happening for some time, though I can't remember how long.

Both Tracker and Terminal show the wrong modification dates for files on my WinXP volume formated with NTFS.


Attachments (3)

r40230-2h_tracker_wrong_dates_on_ntfs.png (62.5 KB) - added by Disreali 3 years ago.
r40230-2h_terminal_wrong_dates_on_ntfs_volume.png (51.8 KB) - added by Disreali 3 years ago.
winxp_explorer_correct_dates.png (75.3 KB) - added by Disreali 3 years ago.

Download all attachments as: .zip

Change History (11)

Changed 3 years ago by Disreali

Changed 3 years ago by Disreali

comment:1 Changed 3 years ago by diver

  • Component changed from - General to File Systems/NTFS
  • Owner changed from nobody to 3dEyes

comment:2 Changed 3 years ago by richienyhus

I had this back in hrev40074.

comment:3 Changed 3 years ago by stargatefan

It has been an issue since at least 38xxx

comment:4 Changed 3 years ago by Disreali

Still present on hrev40500.

comment:5 follow-up: Changed 3 years ago by korli

The obvious bug is at the following lines in src/add-ons/kernel/file_systems/ntfs/fs_func.c in fs_rstat():

        stbuf->st_atime = ni->last_access_time;
        stbuf->st_ctime = ni->last_mft_change_time;
        stbuf->st_mtime = ni->last_data_change_time;

st_atime, st_ctime, st_mtime are actually time_t

#define st_atime        st_atim.tv_sec
#define st_mtime        st_mtim.tv_sec
#define st_ctime        st_ctim.tv_sec

The code should look like the following, unless I miss something. ntfs2timespec is available in ntfstime.h.

    stbuf->st_atim = ntfs2timespec(ni->last_access_time);
    stbuf->st_mtim = ntfs2timespec(ni->last_data_change_time);
    stbuf->st_ctim = ntfs2timespec(ni->last_mft_change_time);

comment:6 in reply to: ↑ 5 Changed 3 years ago by bonefish

Replying to korli:

The code should look like the following, unless I miss something. ntfs2timespec is available in ntfstime.h.

    stbuf->st_atim = ntfs2timespec(ni->last_access_time);
    stbuf->st_mtim = ntfs2timespec(ni->last_data_change_time);
    stbuf->st_ctim = ntfs2timespec(ni->last_mft_change_time);

Agreed. NTFS times seem to be in 1/10 microseconds with another base, so some kind of conversion is needed. And although ATM it is not strictly necessary to set the nanoseconds fields (the VFS clears them) the suggested solution also makes use of the additional precision, which is definitely the best thing to do.

comment:7 Changed 3 years ago by korli

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in hrev40536.

comment:8 Changed 3 years ago by Disreali

Confirmed. Thanks

Note: See TracTickets for help on using tickets.