diff --git a/deps/sefs b/deps/sefs index 62827eb7..9b475b0e 160000 --- a/deps/sefs +++ b/deps/sefs @@ -1 +1 @@ -Subproject commit 62827eb7bb979f70fc2dad1d957ba19016214441 +Subproject commit 9b475b0efdb5a262938d716f4f619e47b6ce3d7f diff --git a/src/libos/src/fs/inode_file.rs b/src/libos/src/fs/inode_file.rs index 8715bd7c..289b3f8c 100644 --- a/src/libos/src/fs/inode_file.rs +++ b/src/libos/src/fs/inode_file.rs @@ -8,7 +8,8 @@ lazy_static! { /// The root of file system pub static ref ROOT_INODE: Arc = { let device = Box::new(SgxStorage::new("sefs")); - let sefs = SEFS::open(device, &SgxTimeProvider).expect("failed to open SEFS"); + let sefs = SEFS::open(device, &time::OcclumTimeProvider) + .expect("failed to open SEFS"); sefs.root_inode() }; } diff --git a/src/libos/src/fs/mod.rs b/src/libos/src/fs/mod.rs index 7757a107..fff278e1 100644 --- a/src/libos/src/fs/mod.rs +++ b/src/libos/src/fs/mod.rs @@ -11,6 +11,7 @@ mod inode_file; pub use self::file::{File, FileRef, SgxFile, StdinFile, StdoutFile}; pub use self::file_table::{FileDesc, FileTable}; pub use self::pipe::Pipe; +pub use self::inode_file::INodeFile; pub const O_RDONLY: u32 = 0x00000000; pub const O_WRONLY: u32 = 0x00000001; @@ -28,33 +29,33 @@ pub const O_CLOEXEC: u32 = 0x00080000; pub type off_t = i64; pub fn do_open(path: &str, flags: u32, mode: u32) -> Result { - let open_options = { - let mut open_options = fs_impl::OpenOptions::new(); - - if ((flags & O_TRUNC) != 0 || (flags & O_CREAT) != 0) { - open_options.write(true); - } else { - open_options.read(true); - } - open_options.update(true).binary(true); - - open_options - }; - - let mut sgx_file = { - let key: sgx_key_128bit_t = [0 as uint8_t; 16]; - // TODO: what if two processes open the same underlying SGX file? - let sgx_file = open_options - .open_ex(path, &key) - .map_err(|e| (Errno::ENOENT, "Failed to open the SGX-protected file"))?; - Arc::new(SgxMutex::new(sgx_file)) - }; +// let open_options = { +// let mut open_options = fs_impl::OpenOptions::new(); +// +// if ((flags & O_TRUNC) != 0 || (flags & O_CREAT) != 0) { +// open_options.write(true); +// } else { +// open_options.read(true); +// } +// open_options.update(true).binary(true); +// +// open_options +// }; +// +// let mut sgx_file = { +// let key: sgx_key_128bit_t = [0 as uint8_t; 16]; +// // TODO: what if two processes open the same underlying SGX file? +// let sgx_file = open_options +// .open_ex(path, &key) +// .map_err(|e| (Errno::ENOENT, "Failed to open the SGX-protected file"))?; +// Arc::new(SgxMutex::new(sgx_file)) +// }; let is_readable = (flags & O_WRONLY) == 0; let is_writable = (flags & O_WRONLY != 0) || (flags & O_RDWR != 0); let is_append = (flags & O_APPEND != 0); - let file_ref: Arc> = Arc::new(Box::new(SgxFile::new( - sgx_file, + let file_ref: Arc> = Arc::new(Box::new(INodeFile::open( + path, is_readable, is_writable, is_append, diff --git a/src/libos/src/time/mod.rs b/src/libos/src/time/mod.rs index 82d6236e..0bf172fd 100644 --- a/src/libos/src/time/mod.rs +++ b/src/libos/src/time/mod.rs @@ -1,4 +1,6 @@ use super::*; +use rcore_fs::dev::TimeProvider; +use rcore_fs::vfs::Timespec; #[allow(non_camel_case_types)] pub type time_t = i64; @@ -24,3 +26,15 @@ pub fn do_gettimeofday() -> timeval_t { extern "C" { fn ocall_gettimeofday(sec: *mut time_t, usec: *mut suseconds_t) -> sgx_status_t; } + +pub struct OcclumTimeProvider; + +impl TimeProvider for OcclumTimeProvider { + fn current_time(&self) -> Timespec { + let time = do_gettimeofday(); + Timespec { + sec: time.sec, + nsec: time.usec as i32 * 1000, + } + } +} \ No newline at end of file