Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
28bd22c
rustdoc: Gate unstable `doc(cfg())` predicates
clubby789 Mar 9, 2025
85b1116
rustdoc: Add FIXME test for `doc_cfg` interaction with `check_cfg`
clubby789 Mar 10, 2025
aa2c24b
uefi: Add OwnedEvent abstraction
Ayush1325 Mar 8, 2025
bcac931
Update test for SGX now implementing read_buf
thaliaarchi Mar 18, 2025
526a689
std: fs: uefi: Implement canonicalize
Ayush1325 Mar 18, 2025
456eedc
std: fs: uefi: Make lstat call stat
Ayush1325 Mar 18, 2025
80229a2
std: fs: uefi: Implement OpenOptions
Ayush1325 Mar 18, 2025
ec487bf
Test that `supported-crate-types` is `-Zunstable-options`-gated
jieyouxu Mar 18, 2025
83d3197
Add smoke test for `supported-crate-types` print request
jieyouxu Mar 18, 2025
e8cf087
Implement `supported-crate-types` print request
jieyouxu Mar 18, 2025
aafcdda
Document `supported-crate-types` print request in unstable book
jieyouxu Mar 18, 2025
675bfeb
Rebless tests with changed help due to new print request option
jieyouxu Mar 18, 2025
405d1c4
Adjust `rustc-print-info-issue-138612.rs`
jieyouxu Mar 21, 2025
b523301
Add test to ensure no index out of bounds panic (#135474)
reddevilmidzy Mar 14, 2025
c25e4bf
resolve: Avoid some unstable iteration 3
petrochenkov Mar 22, 2025
fa0c951
doc: rename reference #create-a-configtoml to #create-a-bootstraptoml
chiichen Mar 23, 2025
5950c86
Slim `rustc_parse_format` dependencies down
Veykril Mar 17, 2025
0b0773d
Rollup merge of #138236 - Ayush1325:uefi-event, r=petrochenkov
jieyouxu Mar 23, 2025
0631764
Rollup merge of #138293 - clubby789:doc-cfg-gate, r=GuillaumeGomez
jieyouxu Mar 23, 2025
21d89ff
Rollup merge of #138509 - reddevilmidzy:add-test, r=compiler-errors
jieyouxu Mar 23, 2025
16447db
Rollup merge of #138602 - Veykril:push-purxoytpktpu, r=SparrowLii
jieyouxu Mar 23, 2025
34892c1
Rollup merge of #138631 - thaliaarchi:sgx-read-buf-test, r=workingjub…
jieyouxu Mar 23, 2025
51e1840
Rollup merge of #138641 - jieyouxu:print-supported-crate-types, r=Urgau
jieyouxu Mar 23, 2025
22f8caa
Rollup merge of #138662 - Ayush1325:uefi-fs-1, r=nicholasbishop,petro…
jieyouxu Mar 23, 2025
7b54a2f
Rollup merge of #138837 - petrochenkov:resinstab2, r=jieyouxu
jieyouxu Mar 23, 2025
5c17679
Rollup merge of #138849 - chiichen:dev/master/doc-correct-configtoml,…
jieyouxu Mar 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
std: fs: uefi: Implement OpenOptions
UEFI does not have specific modes for create_new, truncate and append.
So those need to to be simulated after opening the file.

Signed-off-by: Ayush Singh <[email protected]>
  • Loading branch information
Ayush1325 committed Mar 18, 2025
commit 80229a2d3f73327b5f51fa5a31cc0eb389b9f058
65 changes: 57 additions & 8 deletions library/std/src/sys/fs/uefi.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use r_efi::protocols::file;

use crate::ffi::OsString;
use crate::fmt;
use crate::hash::Hash;
Expand All @@ -22,7 +24,12 @@ pub struct ReadDir(!);
pub struct DirEntry(!);

#[derive(Clone, Debug)]
pub struct OpenOptions {}
pub struct OpenOptions {
mode: u64,
append: bool,
truncate: bool,
create_new: bool,
}

#[derive(Copy, Clone, Debug, Default)]
pub struct FileTimes {}
Expand Down Expand Up @@ -141,15 +148,57 @@ impl DirEntry {

impl OpenOptions {
pub fn new() -> OpenOptions {
OpenOptions {}
OpenOptions { mode: 0, append: false, create_new: false, truncate: false }
}

pub fn read(&mut self, read: bool) {
if read {
self.mode |= file::MODE_READ;
} else {
self.mode &= !file::MODE_READ;
}
}

pub fn read(&mut self, _read: bool) {}
pub fn write(&mut self, _write: bool) {}
pub fn append(&mut self, _append: bool) {}
pub fn truncate(&mut self, _truncate: bool) {}
pub fn create(&mut self, _create: bool) {}
pub fn create_new(&mut self, _create_new: bool) {}
pub fn write(&mut self, write: bool) {
if write {
// Valid Combinations: Read, Read/Write, Read/Write/Create
self.read(true);
self.mode |= file::MODE_WRITE;
} else {
self.mode &= !file::MODE_WRITE;
}
}

pub fn append(&mut self, append: bool) {
// Docs state that `.write(true).append(true)` has the same effect as `.append(true)`
if append {
self.write(true);
}
self.append = append;
}

pub fn truncate(&mut self, truncate: bool) {
self.truncate = truncate;
}

pub fn create(&mut self, create: bool) {
if create {
self.mode |= file::MODE_CREATE;
} else {
self.mode &= !file::MODE_CREATE;
}
}

pub fn create_new(&mut self, create_new: bool) {
self.create_new = create_new;
}

const fn is_mode_valid(&self) -> bool {
// Valid Combinations: Read, Read/Write, Read/Write/Create
self.mode == file::MODE_READ
|| self.mode == (file::MODE_READ | file::MODE_WRITE)
|| self.mode == (file::MODE_READ | file::MODE_WRITE | file::MODE_CREATE)
}
}

impl File {
Expand Down
Loading