Author: ed
Date: Wed Jul 15 11:27:34 2015
New Revision: 285598
URL: https://svnweb.freebsd.org/changeset/base/285598

Log:
  Implement the trivial socket system calls: shutdown() and listen().

Modified:
  head/sys/compat/cloudabi/cloudabi_sock.c

Modified: head/sys/compat/cloudabi/cloudabi_sock.c
==============================================================================
--- head/sys/compat/cloudabi/cloudabi_sock.c    Wed Jul 15 09:24:45 2015        
(r285597)
+++ head/sys/compat/cloudabi/cloudabi_sock.c    Wed Jul 15 11:27:34 2015        
(r285598)
@@ -26,7 +26,11 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include <sys/socket.h>
+#include <sys/sysproto.h>
+
 #include <compat/cloudabi/cloudabi_proto.h>
+#include <compat/cloudabi/cloudabi_syscalldefs.h>
 
 int
 cloudabi_sys_sock_accept(struct thread *td,
@@ -59,18 +63,37 @@ int
 cloudabi_sys_sock_listen(struct thread *td,
     struct cloudabi_sys_sock_listen_args *uap)
 {
+       struct listen_args listen_args = {
+               .s = uap->s,
+               .backlog = uap->backlog,
+       };
 
-       /* Not implemented. */
-       return (ENOSYS);
+       return (sys_listen(td, &listen_args));
 }
 
 int
 cloudabi_sys_sock_shutdown(struct thread *td,
     struct cloudabi_sys_sock_shutdown_args *uap)
 {
+       struct shutdown_args shutdown_args = {
+               .s = uap->fd,
+       };
+
+       switch (uap->how) {
+       case CLOUDABI_SHUT_RD:
+               shutdown_args.how = SHUT_RD;
+               break;
+       case CLOUDABI_SHUT_WR:
+               shutdown_args.how = SHUT_WR;
+               break;
+       case CLOUDABI_SHUT_RD | CLOUDABI_SHUT_WR:
+               shutdown_args.how = SHUT_RDWR;
+               break;
+       default:
+               return (EINVAL);
+       }
 
-       /* Not implemented. */
-       return (ENOSYS);
+       return (sys_shutdown(td, &shutdown_args));
 }
 
 int
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to