Skip to content

Commit 1833737

Browse files
committed
uefi: fs: Implement FilePermission
- UEFI file permissions are indicated using a u64 bitfield used for readonly/filetype, etc. - Using normal bool with to and from attribute conversions to FilePermission from overriding some other bitfields. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
1 parent 2b4694a commit 1833737

1 file changed

Lines changed: 16 additions & 21 deletions

File tree

‎library/std/src/sys/fs/uefi.rs‎

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ use crate::path::{Path, PathBuf};
66
usecrate::sys::time::SystemTime;
77
usecrate::sys::unsupported;
88

9+
#[expect(dead_code)]
10+
constFILE_PERMISSIONS_MASK:u64 = r_efi::protocols::file::READ_ONLY;
11+
912
pubstructFile(!);
1013

1114
pubstructFileAttr(!);
@@ -20,7 +23,9 @@ pub struct OpenOptions {}
2023
#[derive(Copy,Clone,Debug,Default)]
2124
pubstructFileTimes{}
2225

23-
pubstructFilePermissions(!);
26+
#[derive(Clone,PartialEq,Eq,Debug)]
27+
// Bool indicates if file is readonly
28+
pubstructFilePermissions(bool);
2429

2530
pubstructFileType(!);
2631

@@ -64,28 +69,18 @@ impl FilePermissions {
6469
self.0
6570
}
6671

67-
pubfnset_readonly(&mutself,_readonly:bool){
68-
self.0
72+
pubfnset_readonly(&mutself,readonly:bool){
73+
self.0 = readonly
6974
}
70-
}
7175

72-
implCloneforFilePermissions{
73-
fnclone(&self) -> FilePermissions{
74-
self.0
76+
#[expect(dead_code)]
77+
constfnfrom_attr(attr:u64) -> Self{
78+
Self(attr & r_efi::protocols::file::READ_ONLY != 0)
7579
}
76-
}
7780

78-
implPartialEqforFilePermissions{
79-
fneq(&self,_other:&FilePermissions) -> bool{
80-
self.0
81-
}
82-
}
83-
84-
implEqforFilePermissions{}
85-
86-
impl fmt::DebugforFilePermissions{
87-
fnfmt(&self,_f:&mut fmt::Formatter<'_>) -> fmt::Result{
88-
self.0
81+
#[expect(dead_code)]
82+
constfnto_attr(&self) -> u64{
83+
ifself.0{ r_efi::protocols::file::READ_ONLY}else{0}
8984
}
9085
}
9186

@@ -303,8 +298,8 @@ pub fn rename(_old: &Path, _new: &Path) -> io::Result<()> {
303298
unsupported()
304299
}
305300

306-
pubfnset_perm(_p:&Path,perm:FilePermissions) -> io::Result<()>{
307-
match perm.0{}
301+
pubfnset_perm(_p:&Path,_perm:FilePermissions) -> io::Result<()>{
302+
unsupported()
308303
}
309304

310305
pubfnrmdir(_p:&Path) -> io::Result<()>{

0 commit comments

Comments
 (0)