optimize imports and run cargo fmt
				
					
				
			This commit is contained in:
		
							parent
							
								
									4e8801850d
								
							
						
					
					
						commit
						6c61ab5f56
					
				| @ -1,8 +1,8 @@ | |||||||
| use super::*; | use rcore_fs::vfs::{FileSystem, FsError, INode}; | ||||||
| 
 | use rcore_fs_sefs::SEFS; | ||||||
| use std::fmt; | use std::fmt; | ||||||
| use rcore_fs::vfs::{INode, FileSystem, FsError}; | 
 | ||||||
| use rcore_fs_sefs::{SEFS}; | use super::*; | ||||||
| use super::sgx_impl::SgxStorage; | use super::sgx_impl::SgxStorage; | ||||||
| 
 | 
 | ||||||
| lazy_static! { | lazy_static! { | ||||||
| @ -70,7 +70,6 @@ impl File for INodeFile { | |||||||
|         Ok(len) |         Ok(len) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     fn readv(&self, bufs: &mut [&mut [u8]]) -> Result<usize, Error> { |     fn readv(&self, bufs: &mut [&mut [u8]]) -> Result<usize, Error> { | ||||||
|         if !self.options.read { |         if !self.options.read { | ||||||
|             return Err(Error::new(Errno::EBADF, "File not readable")); |             return Err(Error::new(Errno::EBADF, "File not readable")); | ||||||
| @ -82,7 +81,7 @@ impl File for INodeFile { | |||||||
|                 Ok(len) => { |                 Ok(len) => { | ||||||
|                     total_len += len; |                     total_len += len; | ||||||
|                     *offset += len; |                     *offset += len; | ||||||
|                 }, |                 } | ||||||
|                 Err(_) if total_len != 0 => break, |                 Err(_) if total_len != 0 => break, | ||||||
|                 Err(e) => return Err(e.into()), |                 Err(e) => return Err(e.into()), | ||||||
|             } |             } | ||||||
| @ -105,7 +104,7 @@ impl File for INodeFile { | |||||||
|                 Ok(len) => { |                 Ok(len) => { | ||||||
|                     total_len += len; |                     total_len += len; | ||||||
|                     *offset += len; |                     *offset += len; | ||||||
|                 }, |                 } | ||||||
|                 Err(_) if total_len != 0 => break, |                 Err(_) if total_len != 0 => break, | ||||||
|                 Err(e) => return Err(e.into()), |                 Err(e) => return Err(e.into()), | ||||||
|             } |             } | ||||||
| @ -191,8 +190,12 @@ impl From<FsError> for Error { | |||||||
| 
 | 
 | ||||||
| impl Debug for INodeFile { | impl Debug for INodeFile { | ||||||
|     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||||||
|         write!(f, "INodeFile {{ inode: ???, pos: {}, options: {:?} }}", |         write!( | ||||||
|                *self.offset.lock().unwrap(), self.options) |             f, | ||||||
|  |             "INodeFile {{ inode: ???, pos: {}, options: {:?} }}", | ||||||
|  |             *self.offset.lock().unwrap(), | ||||||
|  |             self.options | ||||||
|  |         ) | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -204,7 +207,9 @@ impl INodeExt for INode { | |||||||
|     fn read_as_vec(&self) -> Result<Vec<u8>, Error> { |     fn read_as_vec(&self) -> Result<Vec<u8>, Error> { | ||||||
|         let size = self.metadata()?.size; |         let size = self.metadata()?.size; | ||||||
|         let mut buf = Vec::with_capacity(size); |         let mut buf = Vec::with_capacity(size); | ||||||
|         unsafe { buf.set_len(size); } |         unsafe { | ||||||
|  |             buf.set_len(size); | ||||||
|  |         } | ||||||
|         self.read_at(0, buf.as_mut_slice())?; |         self.read_at(0, buf.as_mut_slice())?; | ||||||
|         Ok(buf) |         Ok(buf) | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -1,21 +1,22 @@ | |||||||
| use super::*; |  | ||||||
| use prelude::*; |  | ||||||
| use std::sgxfs as fs_impl; |  | ||||||
| use {process, std}; | use {process, std}; | ||||||
|  | use prelude::*; | ||||||
|  | use process::Process; | ||||||
|  | use rcore_fs::vfs::{FileType, FsError, INode, Metadata, Timespec}; | ||||||
|  | use std::sgxfs as fs_impl; | ||||||
| 
 | 
 | ||||||
| mod file; | use super::*; | ||||||
| mod file_table; |  | ||||||
| mod pipe; |  | ||||||
| mod inode_file; |  | ||||||
| mod sgx_impl; |  | ||||||
| 
 | 
 | ||||||
| pub use self::file::{File, FileRef, SgxFile, StdinFile, StdoutFile}; | pub use self::file::{File, FileRef, SgxFile, StdinFile, StdoutFile}; | ||||||
| pub use self::file_table::{FileDesc, FileTable}; | pub use self::file_table::{FileDesc, FileTable}; | ||||||
| pub use self::pipe::Pipe; | pub use self::inode_file::{INodeExt, INodeFile, ROOT_INODE}; | ||||||
| pub use self::inode_file::{INodeFile, ROOT_INODE, INodeExt}; |  | ||||||
| use rcore_fs::vfs::{FsError, FileType, INode, Metadata, Timespec}; |  | ||||||
| use self::inode_file::OpenOptions; | use self::inode_file::OpenOptions; | ||||||
| use process::Process; | pub use self::pipe::Pipe; | ||||||
|  | 
 | ||||||
|  | mod file; | ||||||
|  | mod file_table; | ||||||
|  | mod inode_file; | ||||||
|  | mod pipe; | ||||||
|  | mod sgx_impl; | ||||||
| 
 | 
 | ||||||
| // TODO: use the type defined in Rust libc.
 | // TODO: use the type defined in Rust libc.
 | ||||||
| //
 | //
 | ||||||
| @ -26,13 +27,15 @@ pub type off_t = i64; | |||||||
| 
 | 
 | ||||||
| pub fn do_open(path: &str, flags: u32, mode: u32) -> Result<FileDesc, Error> { | pub fn do_open(path: &str, flags: u32, mode: u32) -> Result<FileDesc, Error> { | ||||||
|     let flags = OpenFlags::from_bits_truncate(flags); |     let flags = OpenFlags::from_bits_truncate(flags); | ||||||
|     info!("open: path: {:?}, flags: {:?}, mode: {:#o}", path, flags, mode); |     info!( | ||||||
|  |         "open: path: {:?}, flags: {:?}, mode: {:#o}", | ||||||
|  |         path, flags, mode | ||||||
|  |     ); | ||||||
| 
 | 
 | ||||||
|     let current_ref = process::get_current(); |     let current_ref = process::get_current(); | ||||||
|     let mut proc = current_ref.lock().unwrap(); |     let mut proc = current_ref.lock().unwrap(); | ||||||
| 
 | 
 | ||||||
|     let inode = |     let inode = if flags.contains(OpenFlags::CREATE) { | ||||||
|         if flags.contains(OpenFlags::CREATE) { |  | ||||||
|         let (dir_path, file_name) = split_path(&path); |         let (dir_path, file_name) = split_path(&path); | ||||||
|         let dir_inode = proc.lookup_inode(dir_path)?; |         let dir_inode = proc.lookup_inode(dir_path)?; | ||||||
|         match dir_inode.find(file_name) { |         match dir_inode.find(file_name) { | ||||||
| @ -41,19 +44,15 @@ pub fn do_open(path: &str, flags: u32, mode: u32) -> Result<FileDesc, Error> { | |||||||
|                     return Err(Error::new(EEXIST, "file exists")); |                     return Err(Error::new(EEXIST, "file exists")); | ||||||
|                 } |                 } | ||||||
|                 file_inode |                 file_inode | ||||||
|                 }, |  | ||||||
|                 Err(FsError::EntryNotFound) => { |  | ||||||
|                     dir_inode.create(file_name, FileType::File, mode)? |  | ||||||
|             } |             } | ||||||
|  |             Err(FsError::EntryNotFound) => dir_inode.create(file_name, FileType::File, mode)?, | ||||||
|             Err(e) => return Err(Error::from(e)), |             Err(e) => return Err(Error::from(e)), | ||||||
|         } |         } | ||||||
|     } else { |     } else { | ||||||
|         proc.lookup_inode(&path)? |         proc.lookup_inode(&path)? | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     let file_ref: Arc<Box<File>> = Arc::new(Box::new( |     let file_ref: Arc<Box<File>> = Arc::new(Box::new(INodeFile::open(inode, flags.to_options())?)); | ||||||
|         INodeFile::open(inode, flags.to_options())? |  | ||||||
|     )); |  | ||||||
| 
 | 
 | ||||||
|     let fd = { |     let fd = { | ||||||
|         let close_on_spawn = flags.contains(OpenFlags::CLOEXEC); |         let close_on_spawn = flags.contains(OpenFlags::CLOEXEC); | ||||||
| @ -178,7 +177,12 @@ pub fn do_ftruncate(fd: FileDesc, len: usize) -> Result<(), Error> { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub fn do_getdents64(fd: FileDesc, buf: &mut [u8]) -> Result<usize, Error> { | pub fn do_getdents64(fd: FileDesc, buf: &mut [u8]) -> Result<usize, Error> { | ||||||
|     info!("getdents64: fd: {}, buf: {:?}, buf_size: {}", fd, buf.as_ptr(), buf.len()); |     info!( | ||||||
|  |         "getdents64: fd: {}, buf: {:?}, buf_size: {}", | ||||||
|  |         fd, | ||||||
|  |         buf.as_ptr(), | ||||||
|  |         buf.len() | ||||||
|  |     ); | ||||||
|     let current_ref = process::get_current(); |     let current_ref = process::get_current(); | ||||||
|     let current_process = current_ref.lock().unwrap(); |     let current_process = current_ref.lock().unwrap(); | ||||||
|     let file_ref = current_process.get_files().get(fd)?; |     let file_ref = current_process.get_files().get(fd)?; | ||||||
| @ -194,7 +198,9 @@ pub fn do_getdents64(fd: FileDesc, buf: &mut [u8]) -> Result<usize, Error> { | |||||||
|         }?; |         }?; | ||||||
|         // TODO: get ino from dirent
 |         // TODO: get ino from dirent
 | ||||||
|         let ok = writer.try_write(0, 0, &name); |         let ok = writer.try_write(0, 0, &name); | ||||||
|         if !ok { break; } |         if !ok { | ||||||
|  |             break; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|     Ok(writer.written_size) |     Ok(writer.written_size) | ||||||
| } | } | ||||||
| @ -591,7 +597,7 @@ impl From<Metadata> for Stat { | |||||||
|             atime: info.atime, |             atime: info.atime, | ||||||
|             mtime: info.mtime, |             mtime: info.mtime, | ||||||
|             ctime: info.ctime, |             ctime: info.ctime, | ||||||
|             _pad0: 0 |             _pad0: 0, | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,3 +1,6 @@ | |||||||
|  | use rcore_fs::dev::TimeProvider; | ||||||
|  | use rcore_fs::vfs::Timespec; | ||||||
|  | use rcore_fs_sefs::dev::*; | ||||||
| use std::boxed::Box; | use std::boxed::Box; | ||||||
| use std::io::{Read, Seek, SeekFrom, Write}; | use std::io::{Read, Seek, SeekFrom, Write}; | ||||||
| use std::path::{Path, PathBuf}; | use std::path::{Path, PathBuf}; | ||||||
| @ -5,18 +8,16 @@ use std::sgxfs::{OpenOptions, remove, SgxFile}; | |||||||
| use std::sync::SgxMutex as Mutex; | use std::sync::SgxMutex as Mutex; | ||||||
| use std::time::{SystemTime, UNIX_EPOCH}; | use std::time::{SystemTime, UNIX_EPOCH}; | ||||||
| 
 | 
 | ||||||
| use rcore_fs::dev::TimeProvider; |  | ||||||
| use rcore_fs::vfs::Timespec; |  | ||||||
| use rcore_fs_sefs::dev::*; |  | ||||||
| 
 |  | ||||||
| pub struct SgxStorage { | pub struct SgxStorage { | ||||||
|     path: PathBuf, |     path: PathBuf, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl SgxStorage { | impl SgxStorage { | ||||||
|     pub fn new(path: impl AsRef<Path>) -> Self { |     pub fn new(path: impl AsRef<Path>) -> Self { | ||||||
| //        assert!(path.as_ref().is_dir());
 |         //        assert!(path.as_ref().is_dir());
 | ||||||
|         SgxStorage { path: path.as_ref().to_path_buf() } |         SgxStorage { | ||||||
|  |             path: path.as_ref().to_path_buf(), | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -26,7 +27,10 @@ impl Storage for SgxStorage { | |||||||
|         path.push(format!("{}", file_id)); |         path.push(format!("{}", file_id)); | ||||||
|         // TODO: key
 |         // TODO: key
 | ||||||
|         let key = [0u8; 16]; |         let key = [0u8; 16]; | ||||||
|         let file = OpenOptions::new().read(true).update(true).open_ex(path, &key) |         let file = OpenOptions::new() | ||||||
|  |             .read(true) | ||||||
|  |             .update(true) | ||||||
|  |             .open_ex(path, &key) | ||||||
|             .expect("failed to open SgxFile"); |             .expect("failed to open SgxFile"); | ||||||
|         Ok(Box::new(LockedFile(Mutex::new(file)))) |         Ok(Box::new(LockedFile(Mutex::new(file)))) | ||||||
|     } |     } | ||||||
| @ -36,7 +40,10 @@ impl Storage for SgxStorage { | |||||||
|         path.push(format!("{}", file_id)); |         path.push(format!("{}", file_id)); | ||||||
|         // TODO: key
 |         // TODO: key
 | ||||||
|         let key = [0u8; 16]; |         let key = [0u8; 16]; | ||||||
|         let file = OpenOptions::new().write(true).update(true).open_ex(path, &key) |         let file = OpenOptions::new() | ||||||
|  |             .write(true) | ||||||
|  |             .update(true) | ||||||
|  |             .open_ex(path, &key) | ||||||
|             .expect("failed to create SgxFile"); |             .expect("failed to create SgxFile"); | ||||||
|         Ok(Box::new(LockedFile(Mutex::new(file)))) |         Ok(Box::new(LockedFile(Mutex::new(file)))) | ||||||
|     } |     } | ||||||
| @ -59,7 +66,8 @@ impl File for LockedFile { | |||||||
|     fn read_at(&self, buf: &mut [u8], offset: usize) -> DevResult<usize> { |     fn read_at(&self, buf: &mut [u8], offset: usize) -> DevResult<usize> { | ||||||
|         let mut file = self.0.lock().unwrap(); |         let mut file = self.0.lock().unwrap(); | ||||||
|         let offset = offset as u64; |         let offset = offset as u64; | ||||||
|         file.seek(SeekFrom::Start(offset)).expect("failed to seek SgxFile"); |         file.seek(SeekFrom::Start(offset)) | ||||||
|  |             .expect("failed to seek SgxFile"); | ||||||
|         let len = file.read(buf).expect("failed to read SgxFile"); |         let len = file.read(buf).expect("failed to read SgxFile"); | ||||||
|         Ok(len) |         Ok(len) | ||||||
|     } |     } | ||||||
| @ -67,7 +75,8 @@ impl File for LockedFile { | |||||||
|     fn write_at(&self, buf: &[u8], offset: usize) -> DevResult<usize> { |     fn write_at(&self, buf: &[u8], offset: usize) -> DevResult<usize> { | ||||||
|         let mut file = self.0.lock().unwrap(); |         let mut file = self.0.lock().unwrap(); | ||||||
|         let offset = offset as u64; |         let offset = offset as u64; | ||||||
|         file.seek(SeekFrom::Start(offset)).expect("failed to seek SgxFile"); |         file.seek(SeekFrom::Start(offset)) | ||||||
|  |             .expect("failed to seek SgxFile"); | ||||||
|         let len = file.write(buf).expect("failed to write SgxFile"); |         let len = file.write(buf).expect("failed to write SgxFile"); | ||||||
|         Ok(len) |         Ok(len) | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -1,13 +1,16 @@ | |||||||
| use self::init_stack::{AuxKey, AuxTable}; | use xmas_elf::{ElfFile, header, program, sections}; | ||||||
| use super::task::Task; | use xmas_elf::symbol_table::Entry; | ||||||
| use super::*; | 
 | ||||||
| use fs::{File, FileDesc, FileTable, StdinFile, StdoutFile, ROOT_INODE, INodeExt}; | use fs::{File, FileDesc, FileTable, INodeExt, ROOT_INODE, StdinFile, StdoutFile}; | ||||||
| use std::ffi::{CStr, CString}; | use std::ffi::{CStr, CString}; | ||||||
| use std::path::Path; | use std::path::Path; | ||||||
| use std::sgxfs::SgxFile; | use std::sgxfs::SgxFile; | ||||||
| use vm::{ProcessVM, VMRangeTrait}; | use vm::{ProcessVM, VMRangeTrait}; | ||||||
| use xmas_elf::symbol_table::Entry; | 
 | ||||||
| use xmas_elf::{header, program, sections, ElfFile}; | use super::*; | ||||||
|  | use super::task::Task; | ||||||
|  | 
 | ||||||
|  | use self::init_stack::{AuxKey, AuxTable}; | ||||||
| 
 | 
 | ||||||
| mod elf_helper; | mod elf_helper; | ||||||
| mod init_stack; | mod init_stack; | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| use super::*; |  | ||||||
| use std::mem; | use std::mem; | ||||||
| 
 | 
 | ||||||
|  | use super::*; | ||||||
|  | 
 | ||||||
| /// Note: this definition must be in sync with task.h
 | /// Note: this definition must be in sync with task.h
 | ||||||
| #[derive(Clone, Debug, Default)] | #[derive(Clone, Debug, Default)] | ||||||
| #[repr(C)] | #[repr(C)] | ||||||
| @ -89,9 +90,7 @@ fn set_current(process: &ProcessRef) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fn reset_current() { | fn reset_current() { | ||||||
|     let mut process_ptr = _CURRENT_PROCESS_PTR.with(|cp| { |     let mut process_ptr = _CURRENT_PROCESS_PTR.with(|cp| cp.replace(0 as *const SgxMutex<Process>)); | ||||||
|         cp.replace(0 as *const SgxMutex<Process>) |  | ||||||
|     }); |  | ||||||
| 
 | 
 | ||||||
|     // Prevent memory leakage
 |     // Prevent memory leakage
 | ||||||
|     unsafe { |     unsafe { | ||||||
|  | |||||||
| @ -1,20 +1,22 @@ | |||||||
| use super::*; | use {fs, process, std, vm}; | ||||||
| use fs::{off_t, FileDesc}; | use fs::{FileDesc, off_t}; | ||||||
|  | use fs::File; | ||||||
| use prelude::*; | use prelude::*; | ||||||
| use process::{pid_t, ChildProcessFilter, FileAction}; | use process::{ChildProcessFilter, FileAction, pid_t}; | ||||||
| use std::ffi::{CStr, CString}; | use std::ffi::{CStr, CString}; | ||||||
| use std::ptr; | use std::ptr; | ||||||
| use time::timeval_t; | use time::timeval_t; | ||||||
| use util::mem_util::from_user::*; | use util::mem_util::from_user::*; | ||||||
| use vm::{VMAreaFlags, VMResizeOptions}; | use vm::{VMAreaFlags, VMResizeOptions}; | ||||||
| use {fs, process, std, vm}; | 
 | ||||||
|  | use super::*; | ||||||
|  | 
 | ||||||
|  | use self::consts::*; | ||||||
|  | 
 | ||||||
| // Use the internal syscall wrappers from sgx_tstd
 | // Use the internal syscall wrappers from sgx_tstd
 | ||||||
| //use std::libc_fs as fs;
 | //use std::libc_fs as fs;
 | ||||||
| //use std::libc_io as io;
 | //use std::libc_io as io;
 | ||||||
| 
 | 
 | ||||||
| use self::consts::*; |  | ||||||
| use fs::File; |  | ||||||
| 
 |  | ||||||
| mod consts; | mod consts; | ||||||
| 
 | 
 | ||||||
| #[no_mangle] | #[no_mangle] | ||||||
| @ -28,14 +30,27 @@ pub extern "C" fn dispatch_syscall( | |||||||
|     arg4: isize, |     arg4: isize, | ||||||
|     arg5: isize, |     arg5: isize, | ||||||
| ) -> isize { | ) -> isize { | ||||||
|     debug!("syscall {}: {:#x}, {:#x}, {:#x}, {:#x}, {:#x}, {:#x}", num, arg0, arg1, arg2, arg3, arg4, arg5); |     debug!( | ||||||
|  |         "syscall {}: {:#x}, {:#x}, {:#x}, {:#x}, {:#x}, {:#x}", | ||||||
|  |         num, arg0, arg1, arg2, arg3, arg4, arg5 | ||||||
|  |     ); | ||||||
|     let ret = match num { |     let ret = match num { | ||||||
|         SYS_OPEN => do_open(arg0 as *const i8, arg1 as u32, arg2 as u32), |         SYS_OPEN => do_open(arg0 as *const i8, arg1 as u32, arg2 as u32), | ||||||
|         SYS_CLOSE => do_close(arg0 as FileDesc), |         SYS_CLOSE => do_close(arg0 as FileDesc), | ||||||
|         SYS_READ => do_read(arg0 as FileDesc, arg1 as *mut u8, arg2 as usize), |         SYS_READ => do_read(arg0 as FileDesc, arg1 as *mut u8, arg2 as usize), | ||||||
|         SYS_WRITE => do_write(arg0 as FileDesc, arg1 as *const u8, arg2 as usize), |         SYS_WRITE => do_write(arg0 as FileDesc, arg1 as *const u8, arg2 as usize), | ||||||
|         SYS_PREAD64 => do_pread(arg0 as FileDesc, arg1 as *mut u8, arg2 as usize, arg3 as usize), |         SYS_PREAD64 => do_pread( | ||||||
|         SYS_PWRITE64 => do_pwrite(arg0 as FileDesc, arg1 as *const u8, arg2 as usize, arg3 as usize), |             arg0 as FileDesc, | ||||||
|  |             arg1 as *mut u8, | ||||||
|  |             arg2 as usize, | ||||||
|  |             arg3 as usize, | ||||||
|  |         ), | ||||||
|  |         SYS_PWRITE64 => do_pwrite( | ||||||
|  |             arg0 as FileDesc, | ||||||
|  |             arg1 as *const u8, | ||||||
|  |             arg2 as usize, | ||||||
|  |             arg3 as usize, | ||||||
|  |         ), | ||||||
|         SYS_READV => do_readv(arg0 as FileDesc, arg1 as *mut iovec_t, arg2 as i32), |         SYS_READV => do_readv(arg0 as FileDesc, arg1 as *mut iovec_t, arg2 as i32), | ||||||
|         SYS_WRITEV => do_writev(arg0 as FileDesc, arg1 as *mut iovec_t, arg2 as i32), |         SYS_WRITEV => do_writev(arg0 as FileDesc, arg1 as *mut iovec_t, arg2 as i32), | ||||||
|         SYS_STAT => do_stat(arg0 as *const i8, arg1 as *mut fs::Stat), |         SYS_STAT => do_stat(arg0 as *const i8, arg1 as *mut fs::Stat), | ||||||
| @ -171,7 +186,10 @@ fn do_spawn( | |||||||
|     let envp = clone_cstrings_safely(envp)?; |     let envp = clone_cstrings_safely(envp)?; | ||||||
|     let file_actions = clone_file_actions_safely(fdop_list)?; |     let file_actions = clone_file_actions_safely(fdop_list)?; | ||||||
|     let parent = process::get_current(); |     let parent = process::get_current(); | ||||||
|     info!("spawn: path: {:?}, argv: {:?}, envp: {:?}, fdop: {:?}", path, argv, envp, file_actions); |     info!( | ||||||
|  |         "spawn: path: {:?}, argv: {:?}, envp: {:?}, fdop: {:?}", | ||||||
|  |         path, argv, envp, file_actions | ||||||
|  |     ); | ||||||
| 
 | 
 | ||||||
|     let child_pid = process::do_spawn(&path, &argv, &envp, &file_actions, &parent)?; |     let child_pid = process::do_spawn(&path, &argv, &envp, &file_actions, &parent)?; | ||||||
| 
 | 
 | ||||||
| @ -281,7 +299,9 @@ fn do_stat(path: *const i8, stat_buf: *mut fs::Stat) -> Result<isize, Error> { | |||||||
|     check_mut_ptr(stat_buf)?; |     check_mut_ptr(stat_buf)?; | ||||||
| 
 | 
 | ||||||
|     let stat = fs::do_stat(&path)?; |     let stat = fs::do_stat(&path)?; | ||||||
|     unsafe { stat_buf.write(stat); } |     unsafe { | ||||||
|  |         stat_buf.write(stat); | ||||||
|  |     } | ||||||
|     Ok(0) |     Ok(0) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -289,7 +309,9 @@ fn do_fstat(fd: FileDesc, stat_buf: *mut fs::Stat) -> Result<isize, Error> { | |||||||
|     check_mut_ptr(stat_buf)?; |     check_mut_ptr(stat_buf)?; | ||||||
| 
 | 
 | ||||||
|     let stat = fs::do_fstat(fd)?; |     let stat = fs::do_fstat(fd)?; | ||||||
|     unsafe { stat_buf.write(stat); } |     unsafe { | ||||||
|  |         stat_buf.write(stat); | ||||||
|  |     } | ||||||
|     Ok(0) |     Ok(0) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -298,7 +320,9 @@ fn do_lstat(path: *const i8, stat_buf: *mut fs::Stat) -> Result<isize, Error> { | |||||||
|     check_mut_ptr(stat_buf)?; |     check_mut_ptr(stat_buf)?; | ||||||
| 
 | 
 | ||||||
|     let stat = fs::do_lstat(&path)?; |     let stat = fs::do_lstat(&path)?; | ||||||
|     unsafe { stat_buf.write(stat); } |     unsafe { | ||||||
|  |         stat_buf.write(stat); | ||||||
|  |     } | ||||||
|     Ok(0) |     Ok(0) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -519,8 +543,12 @@ fn do_chdir(path: *const i8) -> Result<isize, Error> { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fn do_rename(oldpath: *const i8, newpath: *const i8) -> Result<isize, Error> { | fn do_rename(oldpath: *const i8, newpath: *const i8) -> Result<isize, Error> { | ||||||
|     let oldpath = clone_cstring_safely(oldpath)?.to_string_lossy().into_owned(); |     let oldpath = clone_cstring_safely(oldpath)? | ||||||
|     let newpath = clone_cstring_safely(newpath)?.to_string_lossy().into_owned(); |         .to_string_lossy() | ||||||
|  |         .into_owned(); | ||||||
|  |     let newpath = clone_cstring_safely(newpath)? | ||||||
|  |         .to_string_lossy() | ||||||
|  |         .into_owned(); | ||||||
|     fs::do_rename(&oldpath, &newpath)?; |     fs::do_rename(&oldpath, &newpath)?; | ||||||
|     Ok(0) |     Ok(0) | ||||||
| } | } | ||||||
| @ -538,8 +566,12 @@ fn do_rmdir(path: *const i8) -> Result<isize, Error> { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fn do_link(oldpath: *const i8, newpath: *const i8) -> Result<isize, Error> { | fn do_link(oldpath: *const i8, newpath: *const i8) -> Result<isize, Error> { | ||||||
|     let oldpath = clone_cstring_safely(oldpath)?.to_string_lossy().into_owned(); |     let oldpath = clone_cstring_safely(oldpath)? | ||||||
|     let newpath = clone_cstring_safely(newpath)?.to_string_lossy().into_owned(); |         .to_string_lossy() | ||||||
|  |         .into_owned(); | ||||||
|  |     let newpath = clone_cstring_safely(newpath)? | ||||||
|  |         .to_string_lossy() | ||||||
|  |         .into_owned(); | ||||||
|     fs::do_link(&oldpath, &newpath)?; |     fs::do_link(&oldpath, &newpath)?; | ||||||
|     Ok(0) |     Ok(0) | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,7 +1,8 @@ | |||||||
| use super::*; |  | ||||||
| use rcore_fs::dev::TimeProvider; | use rcore_fs::dev::TimeProvider; | ||||||
| use rcore_fs::vfs::Timespec; | use rcore_fs::vfs::Timespec; | ||||||
| 
 | 
 | ||||||
|  | use super::*; | ||||||
|  | 
 | ||||||
| #[allow(non_camel_case_types)] | #[allow(non_camel_case_types)] | ||||||
| pub type time_t = i64; | pub type time_t = i64; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -23,8 +23,13 @@ impl Log for SimpleLogger { | |||||||
|         if self.enabled(record.metadata()) { |         if self.enabled(record.metadata()) { | ||||||
|             let color = Color::from(record.level()); |             let color = Color::from(record.level()); | ||||||
|             let (show, code) = color.to_console_code(); |             let (show, code) = color.to_console_code(); | ||||||
|             println!("\u{1B}[{};{}m[{:>5}] {}\u{1B}[0m", |             println!( | ||||||
|                      show, code + 30, record.level(), record.args()); |                 "\u{1B}[{};{}m[{:>5}] {}\u{1B}[0m", | ||||||
|  |                 show, | ||||||
|  |                 code + 30, | ||||||
|  |                 record.level(), | ||||||
|  |                 record.args() | ||||||
|  |             ); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     fn flush(&self) {} |     fn flush(&self) {} | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| use super::*; | use super::*; | ||||||
| 
 | 
 | ||||||
|  | pub mod log; | ||||||
| pub mod mem_util; | pub mod mem_util; | ||||||
| pub mod mpx_util; | pub mod mpx_util; | ||||||
| pub mod ring_buf; | pub mod ring_buf; | ||||||
| pub mod log; |  | ||||||
|  | |||||||
| @ -1,9 +1,11 @@ | |||||||
| use super::*; | use alloc::alloc::{alloc, dealloc, Layout}; | ||||||
|  | 
 | ||||||
| use std::cmp::{max, min}; | use std::cmp::{max, min}; | ||||||
| use std::ptr; | use std::ptr; | ||||||
| use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; |  | ||||||
| use std::sync::Arc; | use std::sync::Arc; | ||||||
| use alloc::alloc::{Layout, alloc, dealloc}; | use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; | ||||||
|  | 
 | ||||||
|  | use super::*; | ||||||
| 
 | 
 | ||||||
| #[derive(Debug)] | #[derive(Debug)] | ||||||
| pub struct RingBuf { | pub struct RingBuf { | ||||||
| @ -44,7 +46,7 @@ struct RingBufInner { | |||||||
|     closed: AtomicBool, // if reader has been dropped
 |     closed: AtomicBool, // if reader has been dropped
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const RING_BUF_ALIGN : usize = 16; | const RING_BUF_ALIGN: usize = 16; | ||||||
| 
 | 
 | ||||||
| impl RingBufInner { | impl RingBufInner { | ||||||
|     fn new(capacity: usize) -> RingBufInner { |     fn new(capacity: usize) -> RingBufInner { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user