Support fstat()

This commit is contained in:
Ian Douglas Scott
2017-07-10 16:43:21 -07:00
parent 7ea19465bb
commit a0bb53c258
+11 -2
View File
@@ -9,9 +9,9 @@ use std::io::{Read, Write};
use std::rc::{Rc, Weak};
use std::str;
use syscall::data::Packet;
use syscall::data::{Packet, Stat};
use syscall::error::{Error, Result, EBADF, EINVAL, ENOENT, EPIPE, EWOULDBLOCK};
use syscall::flag::{F_GETFL, F_SETFL, O_ACCMODE, O_NONBLOCK};
use syscall::flag::{F_GETFL, F_SETFL, O_ACCMODE, O_NONBLOCK, MODE_CHR};
use syscall::scheme::SchemeMut;
pub struct PtyScheme {
@@ -136,6 +136,15 @@ impl SchemeMut for PtyScheme {
Err(Error::new(EBADF))
}
fn fstat(&mut self, _id: usize, stat: &mut Stat) -> Result<usize> {
*stat = Stat {
st_mode: MODE_CHR | 0o666,
..Default::default()
};
Ok(0)
}
fn fsync(&mut self, id: usize) -> Result<usize> {
let slave_opt = self.ptys.1.get(&id).map(|pipe| pipe.clone());
if let Some(pipe) = slave_opt {