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

Commit 233ce7a

Browse files
authored
Merge pull request #102 from registreerocks/he-sgxfs-kv-fix
fix(tenclave): use sgxfs read for correct not-found error handling
2 parents b2f083b + e18c2d0 commit 233ce7a

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

rtc_tenclave/src/kv_store/fs/sgx_filer.rs

Lines changed: 2 additions & 12 deletions
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;
@@ -23,9 +22,8 @@ pub struct SgxFiler;
2322
//
2423
impl Filer for SgxFiler {
2524
fn get(&self, path: impl AsRef<Path>) -> Result<Option<Vec<u8>>> {
26-
// TODO: open_ex with key
27-
let value_file = SgxFile::open(path)?;
28-
match read_all(value_file) {
25+
// TODO: Create `read_ex` to read file with key
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)