Skip to content

fs::stat() returns truncated created, modified, and accessed times #10297

Closed
@williamw520

Description

@williamw520

In 0.9-pre codeline, fs::stat() returns truncated times.

The problem seems to be in uvio::fs_mkstat(). fs::stat() calls io::fs_lstat() which calls uvio::fs_mkstat(). Its to_msec() converts an C time from uv_timespec_t into Rust time.

struct uv_timespec_t {
    tv_sec: libc::c_long,
    tv_nsec: libc::c_long
}

tv_sec and tv_nsec are in c_long, which can be 32-bit. to_msec() multiplies tv_sec with 1000, which will truncate the high bits of a large 32-bit time value. tv_sec needs to be casted to u64 before multiplied with 1000 to avoid the truncation problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions