Implement unix permissions
This commit is contained in:
parent
10c88e7424
commit
f38426e458
19 changed files with 99 additions and 76 deletions
|
@ -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;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit c06edb232b48024a7a8e468dd5316d5b28a3eac9
|
||||
Subproject commit 3dcaad55fe6e82450c1691da5d515861a7deed0a
|
Loading…
Add table
Add a link
Reference in a new issue