-
Notifications
You must be signed in to change notification settings - Fork 13.3k
fix for platform inconsistency in creation time #17272
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
Changes from all commits
fc37a6a
0e304f1
956bacc
6caa237
d6cacd3
5317883
0fe7fd0
ce6849e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -455,11 +455,29 @@ fn mkstat(stat: &libc::stat) -> rtio::FileStat { | |
#[cfg(target_os = "linux")] #[cfg(target_os = "android")] | ||
fn gen(_stat: &libc::stat) -> u64 { 0 } | ||
|
||
#[cfg(target_os = "linux")] | ||
fn created(_stat: &libc::stat) -> u64 { 0 } | ||
#[cfg(target_os = "windows")] | ||
fn created(stat: &libc::stat) -> u64 { mktime(stat.st_ctime as u64, stat.st_ctime_nsec as u64) } | ||
#[cfg(target_os = "macos", target_arch = "x86_64")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this for only 64-bit OSX? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/stat.2.html If you look at the second struct stipulated (the one that contains birthtime), it mentions that that structure is only defined that way when the macro _DARWIN_FEATURE_64_BIT_INODE is defined. Unless 32 bit systems can have this macro defined? |
||
fn created(stat: &libc::stat) -> u64 { | ||
mktime(stat.st_birthtime as u64, stat.st_birthtime_nsec as u64) | ||
} | ||
#[cfg(target_os = "freebsd")] | ||
fn created(stat: &libc::stat) -> u64 { | ||
mktime(stat.st_birthtime as u64, stat.st_birthtime_nsec as u64) | ||
} | ||
#[cfg(target_family = "unix")] | ||
fn changed(stat: &libc::stat) -> u64 { mktime(stat.st_ctime as u64, stat.st_ctime_nsec as u64) } | ||
#[cfg(target_os = "windows")] | ||
fn changed(_stat: &libc::stat) -> u64 { 0 } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this field should be added just yet because windows doesn't support it and the structure of |
||
|
||
rtio::FileStat { | ||
size: stat.st_size as u64, | ||
kind: stat.st_mode as u64, | ||
perm: stat.st_mode as u64, | ||
created: mktime(stat.st_ctime as u64, stat.st_ctime_nsec as u64), | ||
created: created(stat), | ||
changed: changed(stat), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think there's a "changed" field in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wups, will fix. |
||
modified: mktime(stat.st_mtime as u64, stat.st_mtime_nsec as u64), | ||
accessed: mktime(stat.st_atime as u64, stat.st_atime_nsec as u64), | ||
device: stat.st_dev as u64, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @thestinger, surely linux supports this via some means.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the debugfs utility wrestles it out somehow:
http://tecadmin.net/file-creation-time-linux/
We might be able to somehow do this programatically, but it definitely, according to my research, does not come for free. Perhaps that should be a separate PR?