Implement unix permissions

This commit is contained in:
Jeremy Soller 2016-10-05 18:01:05 -06:00
parent 10c88e7424
commit f38426e458
19 changed files with 99 additions and 76 deletions

View file

@ -10,8 +10,8 @@ use syscall::{Packet, Result, Scheme};
struct ExampleScheme;
impl Scheme for ExampleScheme {
fn open(&self, path: &[u8], _flags: usize) -> Result<usize> {
println!("{}", unsafe { str::from_utf8_unchecked(path) });
fn open(&self, path: &[u8], _flags: usize, uid: u32, gid: u32) -> Result<usize> {
println!("{} from {}:{}", unsafe { str::from_utf8_unchecked(path) }, uid, gid);
Ok(0)
}
@ -25,27 +25,6 @@ impl Scheme for ExampleScheme {
}
fn main(){
{
let events = syscall::open("event:", 0).unwrap();
let a = syscall::open("display:", 0).unwrap();
syscall::fevent(a, syscall::EVENT_READ).unwrap();
let b = syscall::open("debug:", 0).unwrap();
syscall::fevent(b, syscall::EVENT_READ).unwrap();
loop {
let mut event = syscall::Event::default();
syscall::read(events, &mut event).unwrap();
println!("{:?}", event);
let mut buf = vec![0; event.data];
syscall::read(event.id, &mut buf).unwrap();
println!("{}", unsafe { ::std::str::from_utf8_unchecked(&buf) });
}
let _ = syscall::close(events);
}
thread::spawn(move || {
let mut socket = File::create(":example").expect("example: failed to create example scheme");
let scheme = ExampleScheme;