Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
williamw520 opened this issue Nov 5, 2013 · 2 comments
Closed

Comments

@williamw520
Copy link

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.

@huonw
Copy link
Member

huonw commented Nov 5, 2013

cc @alexcrichton

@alexcrichton
Copy link
Member

Hm, it appears that my laziness of not wanting to write as u64 twice has come back to haunt me.

Thanks for reporting this! I've fixed this in a local branch which I intend to land soon.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Nov 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants