Opened 13 years ago

Closed 13 years ago

Last modified 13 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:
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 13 years ago.
r40230-2h_terminal_wrong_dates_on_ntfs_volume.png (51.8 KB ) - added by Disreali 13 years ago.
winxp_explorer_correct_dates.png (75.3 KB ) - added by Disreali 13 years ago.

Download all attachments as: .zip

Change History (11)

by Disreali, 13 years ago

comment:1 by diver, 13 years ago

Component: - GeneralFile Systems/NTFS
Owner: changed from nobody to 3dEyes

comment:2 by richienyhus, 13 years ago

I had this back in hrev40074.

comment:3 by stargatefan, 13 years ago

It has been an issue since at least 38xxx

comment:4 by Disreali, 13 years ago

Still present on hrev40500.

comment:5 by korli, 13 years ago

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

in reply to:  5 comment:6 by bonefish, 13 years ago

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 by korli, 13 years ago

Resolution: fixed
Status: newclosed

Fixed in hrev40536.

comment:8 by Disreali, 13 years ago

Confirmed. Thanks

Note: See TracTickets for help on using tickets.