Commit ea4247c0 authored by Tiago's avatar Tiago Committed by Tiago Lam

chan: Support turning unnamed into named sockets.

Previous approach, reverted in commit c7cf2ca0, would break unnamed
sockets - since it assumed there would always be an interim step were
one would first name an unnamed socket, before "listen" / "connect".

Instead of using the same approach as the "tcp:" scheme in Redox's
netstack, which requires an extra mapping of temporary unnamed sockets,
handle the different use cases in dup(). Thus, if a "buf" is provided
that's not a "connect" or "listen", it must be a new path for turning
the unnamed socket into a named socket and should be handled as such.
parent 73570b09
......@@ -211,7 +211,20 @@ impl SchemeBlockMut for ChanScheme {
_ => {
return Err(Error::new(EBADF));
// If a buf is provided, different than "connect" / "listen",
// turn the socket into a named socket.
if buf == b"" {
return Err(Error::new(EBADF));
let handle = self.handles.get_mut(&id).ok_or(Error::new(EBADF))?;
if handle.path.is_some() {
return Err(Error::new(EBADF));
let flags = handle.flags;
return, flags, 0, 0);
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