diff --git a/scheme/env.rs b/scheme/env.rs index 7f2bcb83fcc05494d474b899663c816605910905..807c2736887b950ec3c9de47b537b4ce48614609 100644 --- a/scheme/env.rs +++ b/scheme/env.rs @@ -159,7 +159,7 @@ impl Scheme for EnvScheme { let handle = handles.get(&id).ok_or(Error::new(EBADF))?; stat.st_mode = handle.mode; - stat.st_size = handle.data.lock().len() as u32; //TODO: st_size 64-bit + stat.st_size = handle.data.lock().len() as u64; Ok(0) } diff --git a/scheme/initfs.rs b/scheme/initfs.rs index d23adc755e42ea11193912eff23e1e46bf222479..c3a795c8bfa241a8b64e82650941b57148b03055 100644 --- a/scheme/initfs.rs +++ b/scheme/initfs.rs @@ -130,7 +130,7 @@ impl Scheme for InitFsScheme { let handle = handles.get(&id).ok_or(Error::new(EBADF))?; stat.st_mode = handle.mode; - stat.st_size = handle.data.len() as u32; //TODO: st_size 64-bit + stat.st_size = handle.data.len() as u64; Ok(0) } diff --git a/syscall/process.rs b/syscall/process.rs index d953e42bd688ce3e5d05b33d45be3648ba6babaf..579651239dbb5852f2a7049759814e25c04e6580 100644 --- a/syscall/process.rs +++ b/syscall/process.rs @@ -17,6 +17,7 @@ use context::memory::Grant; use elf::{self, program_header}; use scheme; use syscall; +use syscall::data::Stat; use syscall::error::*; use syscall::flag::{CLONE_VM, CLONE_FS, CLONE_FILES, MAP_WRITE, MAP_WRITE_COMBINE, WNOHANG}; use syscall::validate::{validate_slice, validate_slice_mut}; @@ -391,17 +392,11 @@ pub fn exec(path: &[u8], arg_ptrs: &[[usize; 2]]) -> Result<usize> { } let file = syscall::open(path, 0)?; + let mut stat = Stat::default(); + syscall::fstat(file, &mut stat)?; //TODO: Only read elf header, not entire file. Then read required segments - let mut data = vec![]; - loop { - let mut buf = [0; 16384]; - let count = syscall::read(file, &mut buf)?; - if count > 0 { - data.extend_from_slice(&buf[..count]); - } else { - break; - } - } + let mut data = vec![0; stat.st_size as usize]; + syscall::read(file, &mut data)?; let _ = syscall::close(file); match elf::Elf::from(&data) {