From owner-svn-src-head@freebsd.org Thu Jul 23 13:52:55 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0E8AC9A7F54; Thu, 23 Jul 2015 13:52:55 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F34F5115B; Thu, 23 Jul 2015 13:52:54 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t6NDqsIp075411; Thu, 23 Jul 2015 13:52:54 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t6NDqsn5075410; Thu, 23 Jul 2015 13:52:54 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201507231352.t6NDqsn5075410@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Thu, 23 Jul 2015 13:52:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285812 - head/sys/compat/cloudabi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jul 2015 13:52:55 -0000 Author: ed Date: Thu Jul 23 13:52:53 2015 New Revision: 285812 URL: https://svnweb.freebsd.org/changeset/base/285812 Log: Allow us to create UNIX sockets and socketpairs in CloudABI processes. Modified: head/sys/compat/cloudabi/cloudabi_fd.c Modified: head/sys/compat/cloudabi/cloudabi_fd.c ============================================================================== --- head/sys/compat/cloudabi/cloudabi_fd.c Thu Jul 23 13:22:13 2015 (r285811) +++ head/sys/compat/cloudabi/cloudabi_fd.c Thu Jul 23 13:52:53 2015 (r285812) @@ -46,18 +46,51 @@ int cloudabi_sys_fd_create1(struct thread *td, struct cloudabi_sys_fd_create1_args *uap) { + struct socket_args socket_args = { + .domain = AF_UNIX, + }; - /* Not implemented. */ - return (ENOSYS); + switch (uap->type) { + case CLOUDABI_FILETYPE_SOCKET_DGRAM: + socket_args.type = SOCK_DGRAM; + return (sys_socket(td, &socket_args)); + case CLOUDABI_FILETYPE_SOCKET_SEQPACKET: + socket_args.type = SOCK_SEQPACKET; + return (sys_socket(td, &socket_args)); + case CLOUDABI_FILETYPE_SOCKET_STREAM: + socket_args.type = SOCK_STREAM; + return (sys_socket(td, &socket_args)); + default: + return (EINVAL); + } } int cloudabi_sys_fd_create2(struct thread *td, struct cloudabi_sys_fd_create2_args *uap) { + int fds[2]; + int error; - /* Not implemented. */ - return (ENOSYS); + switch (uap->type) { + case CLOUDABI_FILETYPE_SOCKET_DGRAM: + error = kern_socketpair(td, AF_UNIX, SOCK_DGRAM, 0, fds); + break; + case CLOUDABI_FILETYPE_SOCKET_SEQPACKET: + error = kern_socketpair(td, AF_UNIX, SOCK_SEQPACKET, 0, fds); + break; + case CLOUDABI_FILETYPE_SOCKET_STREAM: + error = kern_socketpair(td, AF_UNIX, SOCK_STREAM, 0, fds); + break; + default: + return (EINVAL); + } + + if (error == 0) { + td->td_retval[0] = fds[0]; + td->td_retval[1] = fds[1]; + } + return (0); } int