64-bit stat size, read entire executable in one go
This commit is contained in:
parent
83ff36a4c3
commit
5e1d2f8c64
|
@ -159,7 +159,7 @@ impl Scheme for EnvScheme {
|
||||||
let handle = handles.get(&id).ok_or(Error::new(EBADF))?;
|
let handle = handles.get(&id).ok_or(Error::new(EBADF))?;
|
||||||
|
|
||||||
stat.st_mode = handle.mode;
|
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)
|
Ok(0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ impl Scheme for InitFsScheme {
|
||||||
let handle = handles.get(&id).ok_or(Error::new(EBADF))?;
|
let handle = handles.get(&id).ok_or(Error::new(EBADF))?;
|
||||||
|
|
||||||
stat.st_mode = handle.mode;
|
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)
|
Ok(0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ use context::memory::Grant;
|
||||||
use elf::{self, program_header};
|
use elf::{self, program_header};
|
||||||
use scheme;
|
use scheme;
|
||||||
use syscall;
|
use syscall;
|
||||||
|
use syscall::data::Stat;
|
||||||
use syscall::error::*;
|
use syscall::error::*;
|
||||||
use syscall::flag::{CLONE_VM, CLONE_FS, CLONE_FILES, MAP_WRITE, MAP_WRITE_COMBINE, WNOHANG};
|
use syscall::flag::{CLONE_VM, CLONE_FS, CLONE_FILES, MAP_WRITE, MAP_WRITE_COMBINE, WNOHANG};
|
||||||
use syscall::validate::{validate_slice, validate_slice_mut};
|
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 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
|
//TODO: Only read elf header, not entire file. Then read required segments
|
||||||
let mut data = vec![];
|
let mut data = vec![0; stat.st_size as usize];
|
||||||
loop {
|
syscall::read(file, &mut data)?;
|
||||||
let mut buf = [0; 16384];
|
|
||||||
let count = syscall::read(file, &mut buf)?;
|
|
||||||
if count > 0 {
|
|
||||||
data.extend_from_slice(&buf[..count]);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let _ = syscall::close(file);
|
let _ = syscall::close(file);
|
||||||
|
|
||||||
match elf::Elf::from(&data) {
|
match elf::Elf::from(&data) {
|
||||||
|
|
2
libstd
2
libstd
|
@ -1 +1 @@
|
||||||
Subproject commit 4dbfda17c3c2e2a0d88687a42151fc8a81f28ca0
|
Subproject commit 9b2e8ea8196cdf8023fb54e8581f94e45b8dec4f
|
|
@ -1 +1 @@
|
||||||
Subproject commit 36b3cf04a9d35b85d481acdf99494fc535152cf0
|
Subproject commit 1488d1ef5661496aff695f2e1bf67997d4654329
|
|
@ -55,17 +55,10 @@ impl DerefMut for Packet {
|
||||||
#[derive(Copy, Clone, Debug, Default)]
|
#[derive(Copy, Clone, Debug, Default)]
|
||||||
#[repr(packed)]
|
#[repr(packed)]
|
||||||
pub struct Stat {
|
pub struct Stat {
|
||||||
pub st_dev: u16,
|
|
||||||
pub st_ino: u16,
|
|
||||||
pub st_mode: u16,
|
pub st_mode: u16,
|
||||||
pub st_nlink: u16,
|
pub st_uid: u32,
|
||||||
pub st_uid: u16,
|
pub st_gid: u32,
|
||||||
pub st_gid: u16,
|
pub st_size: u64
|
||||||
pub st_rdev: u16,
|
|
||||||
pub st_size: u32,
|
|
||||||
pub st_atime: u32,
|
|
||||||
pub st_mtime: u32,
|
|
||||||
pub st_ctime: u32
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for Stat {
|
impl Deref for Stat {
|
||||||
|
|
Loading…
Reference in a new issue