Drop set/get_stdio RPC calls
This commit is contained in:
parent
ae4b3f3d48
commit
230adf0ee0
12
src/main.rs
12
src/main.rs
@ -10,7 +10,6 @@ use parking_lot::RwLock;
|
||||
struct Serv {
|
||||
fs_map: RwLock<HashMap<String, u64>>,
|
||||
mount_list: RwLock<HashMap<PathBuf, (u64, u64)>>,
|
||||
process_stdio: RwLock<HashMap<u64, [Option<(u64, u64)>; 3]>>,
|
||||
syslog_client: syslog_rpc::Client
|
||||
}
|
||||
|
||||
@ -87,16 +86,6 @@ impl vfs_rpc::Server for Serv {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn set_stdio(&self, pid: u64, stdio: [Option<(u64, u64)>; 3]) -> Result<(), Errno> {
|
||||
self.process_stdio.write().insert(pid, stdio);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_stdio(&self, from: u64) -> [Option<(u64, u64)>; 3] {
|
||||
let stdio = self.process_stdio.read().get(&from).copied().unwrap_or([None; 3]);
|
||||
stdio
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@ -109,7 +98,6 @@ fn main() {
|
||||
vfs_rpc::register_server(Box::new(Serv {
|
||||
fs_map: RwLock::new(HashMap::new()),
|
||||
mount_list: RwLock::new(HashMap::new()),
|
||||
process_stdio: RwLock::new(HashMap::new()),
|
||||
syslog_client,
|
||||
}));
|
||||
syscalls::register(0);
|
||||
|
@ -16,8 +16,6 @@ pub trait Server: Send + Sync {
|
||||
fn mount(&self, dev: &Path, kind: &str, path: &Path) -> Result<(), Errno>;
|
||||
fn open(&self, path: &Path) -> Result<(u64, u64), Errno>;
|
||||
fn unmount(&self, path: &Path) -> Result<(), Errno>;
|
||||
fn set_stdio(&self, pid: u64, stdio: [Option<(u64, u64)>; 3]) -> Result<(), Errno>;
|
||||
fn get_stdio(&self, from: u64) -> [Option<(u64, u64)>; 3];
|
||||
fn open_dir(&self, path: &Path) -> Result<(u64, u64), Errno>;
|
||||
}
|
||||
|
||||
@ -69,31 +67,6 @@ impl Client {
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn set_stdio(&self, pid: u64, stdio: [Option<(u64, u64)>; 3]) -> Result<(), Errno> {
|
||||
postcard::from_bytes(
|
||||
&rpc::send_call(
|
||||
self.0,
|
||||
PROTO,
|
||||
4,
|
||||
&postcard::to_stdvec(&(pid, stdio)).unwrap(),
|
||||
)
|
||||
.get_return(),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn get_stdio(&self) -> [Option<(u64, u64)>; 3] {
|
||||
postcard::from_bytes(
|
||||
&rpc::send_call(
|
||||
self.0,
|
||||
PROTO,
|
||||
5,
|
||||
&[],
|
||||
)
|
||||
.get_return(),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn open_dir(self, path: &Path) -> Result<(u64, u64), Errno> {
|
||||
postcard::from_bytes(
|
||||
@ -132,13 +105,6 @@ fn callback(call: IncomingCall) {
|
||||
let path = postcard::from_bytes(call.args()).unwrap();
|
||||
let ret = postcard::to_stdvec(&server.unmount(path)).unwrap();
|
||||
call.send_return(&ret);
|
||||
} else if call.func == 4 {
|
||||
let (pid, stdio) = postcard::from_bytes(call.args()).unwrap();
|
||||
let ret = postcard::to_stdvec(&server.set_stdio(pid, stdio)).unwrap();
|
||||
call.send_return(&ret);
|
||||
} else if call.func == 5 {
|
||||
let ret = postcard::to_stdvec(&server.get_stdio(call.from)).unwrap();
|
||||
call.send_return(&ret);
|
||||
} else if call.func == 6 {
|
||||
let path = postcard::from_bytes(call.args()).unwrap();
|
||||
let ret = postcard::to_stdvec(&server.open_dir (path)).unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user