Merge branch 'encoded_syscall'

This commit is contained in:
Jeremy Soller 2016-10-05 15:43:35 -06:00
commit 10c88e7424
5 changed files with 131 additions and 204 deletions

View file

@ -434,10 +434,10 @@ 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)?;
syscall::file_op_mut_slice(syscall::number::SYS_FSTAT, file, &mut stat)?;
//TODO: Only read elf header, not entire file. Then read required segments
let mut data = vec![0; stat.st_size as usize];
syscall::read(file, &mut data)?;
syscall::file_op_mut_slice(syscall::number::SYS_READ, file, &mut data)?;
let _ = syscall::close(file);
match elf::Elf::from(&data) {