platform/redox: Support AF_UNIX in socket.

To add support for UNIX sockets (AF_UNIX), of SOCK_STREAM type, the
"chan:" scheme is used, which will be supportedby the ipcd running in
userspace.

Later commits add similar AF_UNIX support for the rest of the methods in
impl PalSocket.
This commit is contained in:
Tiago Lam
2020-02-05 22:35:50 +00:00
committed by Tiago Lam
parent 2bc667f71c
commit 12f6ffd152
+5 -4
View File
@@ -292,7 +292,7 @@ impl PalSocket for Sys {
}
unsafe fn socket(domain: c_int, mut kind: c_int, protocol: c_int) -> c_int {
if domain != AF_INET {
if domain != AF_INET && domain != AF_UNIX {
errno = syscall::EAFNOSUPPORT;
return -1;
}
@@ -313,9 +313,10 @@ impl PalSocket for Sys {
// The tcp: and udp: schemes allow using no path,
// and later specifying one using `dup`.
match kind {
SOCK_STREAM => e(syscall::open("tcp:", flags)) as c_int,
SOCK_DGRAM => e(syscall::open("udp:", flags)) as c_int,
match (domain, kind) {
(AF_INET, SOCK_STREAM) => e(syscall::open("tcp:", flags)) as c_int,
(AF_INET, SOCK_DGRAM) => e(syscall::open("udp:", flags)) as c_int,
(AF_UNIX, SOCK_STREAM) => e(syscall::open("chan:", flags | O_CREAT)) as c_int,
_ => {
errno = syscall::EPROTONOSUPPORT;
-1