From e0a9dd31c1998108184c59c3da8812b561017f85 Mon Sep 17 00:00:00 2001 From: Ayush Singh <ayush@beagleboard.org> Date: Sun, 9 Mar 2025 15:50:54 +0530 Subject: [PATCH] uefi: fs: Partially implement FileAttr - Just the permission and file type. - FileTimes will need some new conversion functions and thus will come with a future PR. Trying to keep things simple here. Signed-off-by: Ayush Singh <ayush@beagleboard.org> --- library/std/src/sys/fs/uefi.rs | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/library/std/src/sys/fs/uefi.rs b/library/std/src/sys/fs/uefi.rs index 188f712fb84..56aed7dfd8e 100644 --- a/library/std/src/sys/fs/uefi.rs +++ b/library/std/src/sys/fs/uefi.rs @@ -11,7 +11,11 @@ const FILE_PERMISSIONS_MASK: u64 = r_efi::protocols::file::READ_ONLY; pub struct File(!); -pub struct FileAttr(!); +#[derive(Clone)] +pub struct FileAttr { + attr: u64, + size: u64, +} pub struct ReadDir(!); @@ -36,33 +40,27 @@ pub struct DirBuilder {} impl FileAttr { pub fn size(&self) -> u64 { - self.0 + self.size } pub fn perm(&self) -> FilePermissions { - self.0 + FilePermissions::from_attr(self.attr) } pub fn file_type(&self) -> FileType { - self.0 + FileType::from_attr(self.attr) } pub fn modified(&self) -> io::Result<SystemTime> { - self.0 + unsupported() } pub fn accessed(&self) -> io::Result<SystemTime> { - self.0 + unsupported() } pub fn created(&self) -> io::Result<SystemTime> { - self.0 - } -} - -impl Clone for FileAttr { - fn clone(&self) -> FileAttr { - self.0 + unsupported() } } @@ -75,7 +73,6 @@ impl FilePermissions { self.0 = readonly } - #[expect(dead_code)] const fn from_attr(attr: u64) -> Self { Self(attr & r_efi::protocols::file::READ_ONLY != 0) } @@ -105,7 +102,6 @@ impl FileType { false } - #[expect(dead_code)] const fn from_attr(attr: u64) -> Self { Self(attr & r_efi::protocols::file::DIRECTORY != 0) }