Commit 473ac85f authored by Jeremy Soller's avatar Jeremy Soller

Return error when dup buf is not empty

parent ce78f9cf
......@@ -70,7 +70,11 @@ impl Scheme for DiskScheme {
}
}
fn dup(&self, id: usize, _buf: &[u8]) -> Result<usize> {
fn dup(&self, id: usize, buf: &[u8]) -> Result<usize> {
if ! buf.is_empty() {
return Err(Error::new(EINVAL));
}
let mut handles = self.handles.lock();
let new_handle = {
let handle = handles.get(&id).ok_or(Error::new(EBADF))?;
......
......@@ -1797,7 +1797,11 @@ impl scheme::SchemeMut for Alx {
}
}
fn dup(&mut self, id: usize, _buf: &[u8]) -> Result<usize> {
fn dup(&mut self, id: usize, buf: &[u8]) -> Result<usize> {
if ! buf.is_empty() {
return Err(Error::new(EINVAL));
}
Ok(id)
}
......
......@@ -110,7 +110,11 @@ impl Scheme for Intel8254x {
}
}
fn dup(&self, id: usize, _buf: &[u8]) -> Result<usize> {
fn dup(&self, id: usize, buf: &[u8]) -> Result<usize> {
if ! buf.is_empty() {
return Err(Error::new(EINVAL));
}
Ok(id)
}
......
......@@ -83,7 +83,11 @@ impl SchemeMut for Rtl8168 {
}
}
fn dup(&mut self, id: usize, _buf: &[u8]) -> Result<usize> {
fn dup(&mut self, id: usize, buf: &[u8]) -> Result<usize> {
if ! buf.is_empty() {
return Err(Error::new(EINVAL));
}
Ok(id)
}
......
......@@ -114,7 +114,11 @@ impl SchemeMut for DisplayScheme {
}
}
fn dup(&mut self, id: usize, _buf: &[u8]) -> Result<usize> {
fn dup(&mut self, id: usize, buf: &[u8]) -> Result<usize> {
if ! buf.is_empty() {
return Err(Error::new(EINVAL));
}
let handle = self.handles.get(&id).map(|handle| handle.clone()).ok_or(Error::new(EBADF))?;
let new_id = self.next_id;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment