From 62827eb7bb979f70fc2dad1d957ba19016214441 Mon Sep 17 00:00:00 2001 From: WangRunji Date: Wed, 27 Feb 2019 14:37:04 +0800 Subject: [PATCH] fix SEFS for SGX --- rcore-fs-sefs/Cargo.toml | 2 +- rcore-fs-sefs/src/dev/mod.rs | 4 ++-- rcore-fs-sefs/src/dev/sgx_impl.rs | 11 ++++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/rcore-fs-sefs/Cargo.toml b/rcore-fs-sefs/Cargo.toml index 64da5ed..4f8ae75 100644 --- a/rcore-fs-sefs/Cargo.toml +++ b/rcore-fs-sefs/Cargo.toml @@ -9,7 +9,7 @@ rcore-fs = { path = "../rcore-fs" } static_assertions = "0.3" spin = "0.4" log = "0.4" -sgx_tstd = { version = "1.0.6", optional = true } +sgx_tstd = { path = "../../rust-sgx-sdk/sgx_tstd", optional = true } [dependencies.bitvec] version = "0.9" diff --git a/rcore-fs-sefs/src/dev/mod.rs b/rcore-fs-sefs/src/dev/mod.rs index 38f87a7..484ad15 100644 --- a/rcore-fs-sefs/src/dev/mod.rs +++ b/rcore-fs-sefs/src/dev/mod.rs @@ -5,8 +5,8 @@ use rcore_fs::vfs::FsError; #[cfg(any(test, feature = "std"))] pub use self::std_impl::*; -mod std_impl; -mod sgx_impl; +pub mod std_impl; +pub mod sgx_impl; /// A file stores a normal file or directory. /// diff --git a/rcore-fs-sefs/src/dev/sgx_impl.rs b/rcore-fs-sefs/src/dev/sgx_impl.rs index 2d441f6..fcd056a 100644 --- a/rcore-fs-sefs/src/dev/sgx_impl.rs +++ b/rcore-fs-sefs/src/dev/sgx_impl.rs @@ -6,24 +6,25 @@ use std::path::{Path, PathBuf}; use std::sgxfs::{OpenOptions, remove, SgxFile as File}; use std::sync::SgxMutex as Mutex; use std::time::{SystemTime, UNIX_EPOCH}; +use std::untrusted::time::SystemTimeEx; // FIXME: use trusted ime use rcore_fs::dev::TimeProvider; use rcore_fs::vfs::Timespec; use super::{DeviceError, DevResult}; -pub struct StdStorage { +pub struct SgxStorage { path: PathBuf, } -impl StdStorage { +impl SgxStorage { pub fn new(path: impl AsRef) -> Self { // assert!(path.as_ref().is_dir()); - StdStorage { path: path.as_ref().to_path_buf() } + SgxStorage { path: path.as_ref().to_path_buf() } } } -impl super::Storage for StdStorage { +impl super::Storage for SgxStorage { fn open(&self, file_id: usize) -> DevResult> { let mut path = self.path.to_path_buf(); path.push(format!("{}", file_id)); @@ -96,7 +97,7 @@ impl super::File for LockedFile { pub struct SgxTimeProvider; -impl TimeProvider for StdTimeProvider { +impl TimeProvider for SgxTimeProvider { fn current_time(&self) -> Timespec { let duration = SystemTime::now().duration_since(UNIX_EPOCH).unwrap(); Timespec {