-
Notifications
You must be signed in to change notification settings - Fork 13.7k
uefi: fs: Add file times plumbing #138918
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
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -18,6 +18,8 @@ pub struct File(!); | |
pub struct FileAttr { | ||
attr: u64, | ||
size: u64, | ||
created: r_efi::efi::Time, | ||
times: FileTimes, | ||
} | ||
|
||
pub struct ReadDir(!); | ||
|
@@ -33,7 +35,10 @@ pub struct OpenOptions { | |
} | ||
|
||
#[derive(Copy, Clone, Debug, Default)] | ||
pub struct FileTimes {} | ||
pub struct FileTimes { | ||
accessed: r_efi::efi::Time, | ||
modified: r_efi::efi::Time, | ||
} | ||
|
||
#[derive(Clone, PartialEq, Eq, Debug)] | ||
// Bool indicates if file is readonly | ||
|
@@ -60,15 +65,15 @@ impl FileAttr { | |
} | ||
|
||
pub fn modified(&self) -> io::Result<SystemTime> { | ||
unsupported() | ||
Ok(SystemTime::from_uefi(self.times.modified)) | ||
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. FAT timestamps are always stored in local time in the system timezone, and the EDK II FAT driver uses EFI_UNSPECIFIED_TIMEZONE to represent this. Therefore, if the modified/accessed/created EFI time has a timezone of unspecified, this conversion should use the timezone from the runtime services |
||
} | ||
|
||
pub fn accessed(&self) -> io::Result<SystemTime> { | ||
unsupported() | ||
Ok(SystemTime::from_uefi(self.times.accessed)) | ||
} | ||
|
||
pub fn created(&self) -> io::Result<SystemTime> { | ||
unsupported() | ||
Ok(SystemTime::from_uefi(self.created)) | ||
} | ||
} | ||
|
||
|
@@ -92,8 +97,13 @@ impl FilePermissions { | |
} | ||
|
||
impl FileTimes { | ||
pub fn set_accessed(&mut self, _t: SystemTime) {} | ||
pub fn set_modified(&mut self, _t: SystemTime) {} | ||
pub fn set_accessed(&mut self, t: SystemTime) { | ||
self.accessed = t.to_uefi_loose(self.accessed.timezone, self.accessed.daylight); | ||
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.
|
||
} | ||
|
||
pub fn set_modified(&mut self, t: SystemTime) { | ||
self.modified = t.to_uefi_loose(self.modified.timezone, self.modified.daylight); | ||
} | ||
} | ||
|
||
impl FileType { | ||
|
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.
UEFI allows creation time to be set, so
created
should be part of theFileTimes
struct (a future PR can then use it to implementset_created
in an extension trait like on Windows and Apple platforms).