Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/linux/common implement accept4



details:   https://anonhg.NetBSD.org/src/rev/60f9a7819b89
branches:  trunk
changeset: 351104:60f9a7819b89
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Feb 02 15:36:55 2017 +0000

description:
implement accept4

diffstat:

 sys/compat/linux/common/linux_socket.c |  39 ++++++++++++++++++++++++++++++++-
 1 files changed, 37 insertions(+), 2 deletions(-)

diffs (57 lines):

diff -r 75c8a854a935 -r 60f9a7819b89 sys/compat/linux/common/linux_socket.c
--- a/sys/compat/linux/common/linux_socket.c    Thu Feb 02 15:36:12 2017 +0000
+++ b/sys/compat/linux/common/linux_socket.c    Thu Feb 02 15:36:55 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_socket.c,v 1.133 2016/09/13 07:01:07 martin Exp $        */
+/*     $NetBSD: linux_socket.c,v 1.134 2017/02/02 15:36:55 christos Exp $      */
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.133 2016/09/13 07:01:07 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.134 2017/02/02 15:36:55 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1707,3 +1707,38 @@
 
        return (0);
 }
+
+int
+linux_sys_accept4(struct lwp *l, const struct linux_sys_accept4_args *uap, register_t *retval)
+{
+       /* {
+               syscallarg(int) s;
+               syscallarg(struct osockaddr *) name;
+               syscallarg(int *) anamelen;
+               syscallarg(int) flags;
+       } */
+       int error, flags;
+       struct sockaddr_big name;
+
+       if ((flags = linux_to_bsd_type(SCARG(uap, flags))) == -1)
+               return EINVAL;
+
+       name.sb_len = UCHAR_MAX;
+       error = do_sys_accept(l, SCARG(uap, s), (struct sockaddr *)&name,
+           retval, NULL, flags, 0);
+       if (error != 0)
+               return error;
+
+       error = copyout_sockname_sb((struct sockaddr *)SCARG(uap, name),
+           SCARG(uap, anamelen), MSG_LENUSRSPACE, &name);
+       if (error != 0) {
+               int fd = (int)*retval;
+               if (fd_getfile(fd) != NULL)
+                       (void)fd_close(fd);
+               return error;
+       }
+       if (SCARG(uap, name) && (error = linux_sa_put(SCARG(uap, name))))
+               return error;
+
+       return 0;
+}



Home | Main Index | Thread Index | Old Index