Skip to content
This repository was archived by the owner on May 9, 2022. It is now read-only.

Commit 2535d60

Browse files
committed
fix(tenclave): use sgxfs' read for correct not-found error handling
1 parent 24b6e9c commit 2535d60

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

rtc_tenclave/src/kv_store/fs/sgx_filer.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use std::prelude::v1::Vec;
44

55
use std::io::ErrorKind::NotFound;
6-
use std::io::Read;
76
use std::io::Result;
87
use std::io::Write;
98
use std::path::Path;
@@ -24,8 +23,7 @@ pub struct SgxFiler;
2423
impl Filer for SgxFiler {
2524
fn get(&self, path: impl AsRef<Path>) -> Result<Option<Vec<u8>>> {
2625
// TODO: open_ex with key
27-
let value_file = SgxFile::open(path)?;
28-
match read_all(value_file) {
26+
match sgxfs::read(path) {
2927
Ok(contents) => Ok(Some(contents)),
3028
Err(error) if error.kind() == NotFound => Ok(None),
3129
Err(error) => Err(error),
@@ -46,11 +44,3 @@ impl Filer for SgxFiler {
4644
}
4745
}
4846
}
49-
50-
/// Helper: Like [`fs::read`], but take an open file.
51-
fn read_all(mut file: SgxFile) -> Result<Vec<u8>> {
52-
// XXX: No metadata for initial_buffer_size in sgxfs
53-
let mut buf = Vec::new();
54-
file.read_to_end(&mut buf)?;
55-
Ok(buf)
56-
}

0 commit comments

Comments
 (0)