Source-Changes-HG archive

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

[src/trunk]: src/sys move the COMPAT_SUNOS SO_BROADCAST hack out of uipc_sock...



details:   https://anonhg.NetBSD.org/src/rev/a5349aa0023e
branches:  trunk
changeset: 520104:a5349aa0023e
user:      mrg <mrg%NetBSD.org@localhost>
date:      Thu Jan 03 00:59:00 2002 +0000

description:
move the COMPAT_SUNOS SO_BROADCAST hack out of uipc_socket.c into the
compat/sunos code.  besides being cleaner this allows the sunos LKM
to properly work without any special kernel hacks.

diffstat:

 sys/compat/sunos/sunos_misc.c            |  66 ++++++++++++++++++++++++++++++-
 sys/compat/sunos/sunos_syscall.h         |   4 +-
 sys/compat/sunos/sunos_syscallargs.h     |  21 ++++++++-
 sys/compat/sunos/sunos_syscalls.c        |   6 +-
 sys/compat/sunos/sunos_sysent.c          |  14 +++---
 sys/compat/sunos/syscalls.master         |   6 +-
 sys/compat/sunos32/sunos32_misc.c        |  67 +++++++++++++++++++++++++++++++-
 sys/compat/sunos32/sunos32_syscall.h     |  12 ++--
 sys/compat/sunos32/sunos32_syscallargs.h |   8 +-
 sys/compat/sunos32/sunos32_syscalls.c    |  10 ++--
 sys/compat/sunos32/sunos32_sysent.c      |  14 +++---
 sys/compat/sunos32/syscalls.master       |   6 +-
 sys/kern/uipc_socket.c                   |   6 +-
 13 files changed, 189 insertions(+), 51 deletions(-)

diffs (truncated from 551 to 300 lines):

diff -r 8a4b66d4e5ea -r a5349aa0023e sys/compat/sunos/sunos_misc.c
--- a/sys/compat/sunos/sunos_misc.c     Wed Jan 02 23:58:18 2002 +0000
+++ b/sys/compat/sunos/sunos_misc.c     Thu Jan 03 00:59:00 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sunos_misc.c,v 1.112 2001/12/02 00:35:25 tsutsui Exp $ */
+/*     $NetBSD: sunos_misc.c,v 1.113 2002/01/03 01:11:28 mrg Exp $     */
 
 /*
  * Copyright (c) 1992, 1993
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunos_misc.c,v 1.112 2001/12/02 00:35:25 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunos_misc.c,v 1.113 2002/01/03 01:11:28 mrg Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_nfsserver.h"
@@ -732,6 +732,68 @@
        return (error);
 }
 
+static __inline__ int sunos_sys_socket_common(struct proc *, register_t *,
+                                             int type);
+static __inline__ int
+sunos_sys_socket_common(p, retval, type)
+       struct proc *p;
+       register_t *retval;
+       int type;
+{
+       struct socket *so;
+       struct file *fp;
+       int error, fd;
+
+       /* getsock() will use the descriptor for us */
+       fd = (int)*retval;
+       if ((error = getsock(p->p_fd, fd, &fp)) == 0) {
+               so = (struct socket *)fp->f_data;
+               if (type == SOCK_DGRAM)
+                       so->so_options |= SO_BROADCAST;
+       }
+       FILE_UNUSE(fp, p);
+       return (error);
+}
+
+int
+sunos_sys_socket(p, v, retval)
+       struct proc *p;
+       void *v;
+       register_t *retval;
+{
+       struct sunos_sys_socket_args /* {
+               syscallarg(int) domain;
+               syscallarg(int) type;
+               syscallarg(int) protocol;
+       } */ *uap = v;
+       int error;
+
+       error = sys_socket(p, v, retval);
+       if (error)
+               return (error);
+       return sunos_sys_socket_common(p, retval, SCARG(uap, type));
+}
+
+int
+sunos_sys_socketpair(p, v, retval)
+       struct proc *p;
+       void *v;
+       register_t *retval;
+{
+       struct sunos_sys_socketpair_args /* {
+               syscallarg(int) domain;
+               syscallarg(int) type;
+               syscallarg(int) protocol;
+               syscallarg(int *) rsv;
+       } */ *uap = v;
+       int error;
+
+       error = sys_socketpair(p, v, retval);
+       if (error)
+               return (error);
+       return sunos_sys_socket_common(p, retval, SCARG(uap, type));
+}
+
 /*
  * XXX: This needs cleaning up.
  */
diff -r 8a4b66d4e5ea -r a5349aa0023e sys/compat/sunos/sunos_syscall.h
--- a/sys/compat/sunos/sunos_syscall.h  Wed Jan 02 23:58:18 2002 +0000
+++ b/sys/compat/sunos/sunos_syscall.h  Thu Jan 03 00:59:00 2002 +0000
@@ -1,10 +1,10 @@
-/* $NetBSD: sunos_syscall.h,v 1.66 2001/11/13 02:09:18 lukem Exp $ */
+/* $NetBSD: sunos_syscall.h,v 1.67 2002/01/03 01:11:28 mrg Exp $ */
 
 /*
  * System call numbers.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from        NetBSD: syscalls.master,v 1.58 2001/05/30 11:37:31 mrg Exp 
+ * created from        NetBSD: syscalls.master,v 1.59 2002/01/03 00:59:00 mrg Exp 
  */
 
 /* syscall: "syscall" ret: "int" args: */
diff -r 8a4b66d4e5ea -r a5349aa0023e sys/compat/sunos/sunos_syscallargs.h
--- a/sys/compat/sunos/sunos_syscallargs.h      Wed Jan 02 23:58:18 2002 +0000
+++ b/sys/compat/sunos/sunos_syscallargs.h      Thu Jan 03 00:59:00 2002 +0000
@@ -1,10 +1,10 @@
-/* $NetBSD: sunos_syscallargs.h,v 1.51 2001/11/13 02:09:19 lukem Exp $ */
+/* $NetBSD: sunos_syscallargs.h,v 1.52 2002/01/03 01:11:29 mrg Exp $ */
 
 /*
  * System call argument lists.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from        NetBSD: syscalls.master,v 1.58 2001/05/30 11:37:31 mrg Exp 
+ * created from        NetBSD: syscalls.master,v 1.59 2002/01/03 00:59:00 mrg Exp 
  */
 
 #ifndef _SUNOS_SYS__SYSCALLARGS_H_
@@ -133,6 +133,12 @@
        syscallarg(void *) arg;
 };
 
+struct sunos_sys_socket_args {
+       syscallarg(int) domain;
+       syscallarg(int) type;
+       syscallarg(int) protocol;
+};
+
 struct sunos_sys_setsockopt_args {
        syscallarg(int) s;
        syscallarg(int) level;
@@ -151,6 +157,13 @@
        syscallarg(int) mask;
 };
 
+struct sunos_sys_socketpair_args {
+       syscallarg(int) domain;
+       syscallarg(int) type;
+       syscallarg(int) protocol;
+       syscallarg(int *) rsv;
+};
+
 struct sunos_sys_sigreturn_args {
        syscallarg(struct sigcontext *) sigcntxp;
 };
@@ -303,7 +316,7 @@
 int    sys_select(struct proc *, void *, register_t *);
 int    sys_fsync(struct proc *, void *, register_t *);
 int    sys_setpriority(struct proc *, void *, register_t *);
-int    sys_socket(struct proc *, void *, register_t *);
+int    sunos_sys_socket(struct proc *, void *, register_t *);
 int    sys_connect(struct proc *, void *, register_t *);
 int    compat_43_sys_accept(struct proc *, void *, register_t *);
 int    sys_getpriority(struct proc *, void *, register_t *);
@@ -336,7 +349,7 @@
 int    sys_flock(struct proc *, void *, register_t *);
 int    sys_sendto(struct proc *, void *, register_t *);
 int    sys_shutdown(struct proc *, void *, register_t *);
-int    sys_socketpair(struct proc *, void *, register_t *);
+int    sunos_sys_socketpair(struct proc *, void *, register_t *);
 int    sys_mkdir(struct proc *, void *, register_t *);
 int    sys_rmdir(struct proc *, void *, register_t *);
 int    sys_utimes(struct proc *, void *, register_t *);
diff -r 8a4b66d4e5ea -r a5349aa0023e sys/compat/sunos/sunos_syscalls.c
--- a/sys/compat/sunos/sunos_syscalls.c Wed Jan 02 23:58:18 2002 +0000
+++ b/sys/compat/sunos/sunos_syscalls.c Thu Jan 03 00:59:00 2002 +0000
@@ -1,14 +1,14 @@
-/* $NetBSD: sunos_syscalls.c,v 1.66 2001/11/13 02:09:19 lukem Exp $ */
+/* $NetBSD: sunos_syscalls.c,v 1.67 2002/01/03 01:11:29 mrg Exp $ */
 
 /*
  * System call names.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from        NetBSD: syscalls.master,v 1.58 2001/05/30 11:37:31 mrg Exp 
+ * created from        NetBSD: syscalls.master,v 1.59 2002/01/03 00:59:00 mrg Exp 
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunos_syscalls.c,v 1.66 2001/11/13 02:09:19 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunos_syscalls.c,v 1.67 2002/01/03 01:11:29 mrg Exp $");
 
 #if defined(_KERNEL_OPT)
 #if defined(_KERNEL_OPT)
diff -r 8a4b66d4e5ea -r a5349aa0023e sys/compat/sunos/sunos_sysent.c
--- a/sys/compat/sunos/sunos_sysent.c   Wed Jan 02 23:58:18 2002 +0000
+++ b/sys/compat/sunos/sunos_sysent.c   Thu Jan 03 00:59:00 2002 +0000
@@ -1,14 +1,14 @@
-/* $NetBSD: sunos_sysent.c,v 1.59 2001/11/13 02:09:19 lukem Exp $ */
+/* $NetBSD: sunos_sysent.c,v 1.60 2002/01/03 01:11:29 mrg Exp $ */
 
 /*
  * System call switch table.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from        NetBSD: syscalls.master,v 1.58 2001/05/30 11:37:31 mrg Exp 
+ * created from        NetBSD: syscalls.master,v 1.59 2002/01/03 00:59:00 mrg Exp 
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunos_sysent.c,v 1.59 2001/11/13 02:09:19 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunos_sysent.c,v 1.60 2002/01/03 01:11:29 mrg Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_nfsserver.h"
@@ -221,8 +221,8 @@
            sys_fsync },                        /* 95 = fsync */
        { 3, s(struct sys_setpriority_args), 0,
            sys_setpriority },                  /* 96 = setpriority */
-       { 3, s(struct sys_socket_args), 0,
-           sys_socket },                       /* 97 = socket */
+       { 3, s(struct sunos_sys_socket_args), 0,
+           sunos_sys_socket },                 /* 97 = socket */
        { 3, s(struct sys_connect_args), 0,
            sys_connect },                      /* 98 = connect */
        { 3, s(struct compat_43_sys_accept_args), 0,
@@ -297,8 +297,8 @@
            sys_sendto },                       /* 133 = sendto */
        { 2, s(struct sys_shutdown_args), 0,
            sys_shutdown },                     /* 134 = shutdown */
-       { 4, s(struct sys_socketpair_args), 0,
-           sys_socketpair },                   /* 135 = socketpair */
+       { 4, s(struct sunos_sys_socketpair_args), 0,
+           sunos_sys_socketpair },             /* 135 = socketpair */
        { 2, s(struct sys_mkdir_args), 0,
            sys_mkdir },                        /* 136 = mkdir */
        { 1, s(struct sys_rmdir_args), 0,
diff -r 8a4b66d4e5ea -r a5349aa0023e sys/compat/sunos/syscalls.master
--- a/sys/compat/sunos/syscalls.master  Wed Jan 02 23:58:18 2002 +0000
+++ b/sys/compat/sunos/syscalls.master  Thu Jan 03 00:59:00 2002 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.58 2001/05/30 11:37:31 mrg Exp $
+       $NetBSD: syscalls.master,v 1.59 2002/01/03 00:59:00 mrg Exp $
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -167,7 +167,7 @@
 94     UNIMPL          setdopt
 95     NOARGS          { int sys_fsync(int fd); }
 96     NOARGS          { int sys_setpriority(int which, int who, int prio); }
-97     NOARGS          { int sys_socket(int domain, int type, int protocol); }
+97     STD             { int sunos_sys_socket(int domain, int type, int protocol); }
 98     NOARGS          { int sys_connect(int s, caddr_t name, int namelen); }
 99     NOARGS          { int compat_43_sys_accept(int s, caddr_t name, \
                            int *anamelen); }
@@ -221,7 +221,7 @@
 133    NOARGS          { int sys_sendto(int s, caddr_t buf, size_t len, \
                            int flags, caddr_t to, int tolen); }
 134    NOARGS          { int sys_shutdown(int s, int how); }
-135    NOARGS          { int sys_socketpair(int domain, int type, \
+135    STD             { int sunos_sys_socketpair(int domain, int type, \
                            int protocol, int *rsv); }
 136    NOARGS          { int sys_mkdir(char *path, int mode); }
 137    NOARGS          { int sys_rmdir(char *path); }
diff -r 8a4b66d4e5ea -r a5349aa0023e sys/compat/sunos32/sunos32_misc.c
--- a/sys/compat/sunos32/sunos32_misc.c Wed Jan 02 23:58:18 2002 +0000
+++ b/sys/compat/sunos32/sunos32_misc.c Thu Jan 03 00:59:00 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sunos32_misc.c,v 1.10 2001/11/13 02:09:20 lukem Exp $  */
+/*     $NetBSD: sunos32_misc.c,v 1.11 2002/01/03 01:11:30 mrg Exp $    */
 /* from :NetBSD: sunos_misc.c,v 1.107 2000/12/01 19:25:10 jdolecek Exp */
 
 /*
@@ -83,7 +83,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunos32_misc.c,v 1.10 2001/11/13 02:09:20 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunos32_misc.c,v 1.11 2002/01/03 01:11:30 mrg Exp $");
 
 #define COMPAT_SUNOS 1
 
@@ -972,6 +972,69 @@
        return (error);
 }
 
+static __inline__ int sunos32_sys_socket_common(struct proc *, register_t *,
+                                             int type);
+static __inline__ int
+sunos32_sys_socket_common(p, retval, type)
+       struct proc *p;
+       register_t *retval;
+       int type;
+{
+       struct socket *so;
+       struct file *fp;
+       int error, fd;
+
+       /* getsock() will use the descriptor for us */
+       fd = (int)*retval;
+       if ((error = getsock(p->p_fd, fd, &fp)) == 0) {
+               so = (struct socket *)fp->f_data;
+               if (type == SOCK_DGRAM)
+                       so->so_options |= SO_BROADCAST;
+       }
+       FILE_UNUSE(fp, p);
+       return (error);
+}
+



Home | Main Index | Thread Index | Old Index