Add sys:exe to get current executable

This commit is contained in:
Jeremy Soller 2016-11-14 20:54:33 -07:00
commit a916e29b3c

16
kernel/scheme/sys/exe.rs Normal file
View file

@ -0,0 +1,16 @@
use collections::Vec;
use context;
use syscall::error::{Error, ESRCH, Result};
pub fn resource() -> Result<Vec<u8>> {
let mut name = {
let contexts = context::contexts();
let context_lock = contexts.current().ok_or(Error::new(ESRCH))?;
let context = context_lock.read();
let name = context.name.lock();
name.clone()
};
name.push(b'\n');
Ok(name)
}