Source-Changes-HG archive

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

[src/chs-ubc2]: src/sys/compat Update from trunk.



details:   https://anonhg.NetBSD.org/src/rev/99202d7cc9c7
branches:  chs-ubc2
changeset: 471426:99202d7cc9c7
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Aug 02 21:52:20 1999 +0000

description:
Update from trunk.

diffstat:

 sys/compat/linux/common/linux_misc.c   |    6 +-
 sys/compat/linux/common/linux_socket.c |  118 ++++++++++++++++++++++++++++++++-
 sys/compat/linux/common/linux_sockio.h |    3 +-
 sys/compat/netbsd32/netbsd32_netbsd.c  |    8 +-
 sys/compat/netbsd32/syscalls.master    |    4 +-
 5 files changed, 123 insertions(+), 16 deletions(-)

diffs (236 lines):

diff -r 8c978f3a0524 -r 99202d7cc9c7 sys/compat/linux/common/linux_misc.c
--- a/sys/compat/linux/common/linux_misc.c      Mon Aug 02 21:51:41 1999 +0000
+++ b/sys/compat/linux/common/linux_misc.c      Mon Aug 02 21:52:20 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_misc.c,v 1.53.4.1 1999/06/21 01:07:37 thorpej Exp $      */
+/*     $NetBSD: linux_misc.c,v 1.53.4.2 1999/08/02 21:52:20 thorpej Exp $      */
 
 /*-
  * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
@@ -955,10 +955,6 @@
                return (EINVAL);
        sig = linux_to_native_sig[sig];
 
-       /* XXX Is this the right thing? */
-       if (sig == 0)
-               sig = SIGCHLD;
-
        /*
         * Note that Linux does not provide a portable way of specifying
         * the stack area; the caller must know if the stack grows up
diff -r 8c978f3a0524 -r 99202d7cc9c7 sys/compat/linux/common/linux_socket.c
--- a/sys/compat/linux/common/linux_socket.c    Mon Aug 02 21:51:41 1999 +0000
+++ b/sys/compat/linux/common/linux_socket.c    Mon Aug 02 21:52:20 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_socket.c,v 1.19.4.1 1999/06/21 01:07:38 thorpej Exp $    */
+/*     $NetBSD: linux_socket.c,v 1.19.4.2 1999/08/02 21:52:20 thorpej Exp $    */
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -54,6 +54,8 @@
 #include <sys/socket.h>
 #include <sys/socketvar.h>
 #include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_types.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 #include <sys/mount.h>
@@ -74,6 +76,10 @@
 
 #include <compat/linux/linux_syscallargs.h>
 
+#ifndef MIN
+#define        MIN(a,b) (((a)<(b))?(a):(b))
+#endif
+
 /*
  * The calls in this file are entered either via the linux_socketcall()
  * interface or, on the Alpha, as individual syscalls.  The
@@ -88,6 +94,7 @@
 int linux_to_bsd_ip_sockopt __P((int));
 int linux_to_bsd_tcp_sockopt __P((int));
 int linux_to_bsd_udp_sockopt __P((int));
+int linux_getifhwaddr __P((struct proc *, register_t *, u_int, void *));
 
 /*
  * Convert between Linux and BSD socket domain values
@@ -442,6 +449,112 @@
        return sys_getsockopt(p, &bga, retval);
 }
 
+#define IF_NAME_LEN 16
+
+int
+linux_getifhwaddr(p, retval, fd, data)
+       struct proc *p;
+       register_t *retval;
+       u_int fd;
+       void *data;
+{
+       /* Not the full structure, just enough to map what we do here */
+       struct linux_ifreq {
+               char if_name[IF_NAME_LEN];
+               struct osockaddr hwaddr;
+       } lreq;
+       struct filedesc *fdp;
+       struct file *fp;
+       struct ifaddr *ifa;
+       struct ifnet *ifp;
+       struct sockaddr_dl *sadl;
+       int error, found;
+       int index, ifnum;
+
+       /*
+        * We can't emulate this ioctl by calling sys_ioctl() to run
+        * SIOCGIFCONF, because the user buffer is not of the right
+        * type to take those results.  We can't use kernel buffers to
+        * receive the results, as the implementation of sys_ioctl()
+        * and ifconf() [which implements SIOCGIFCONF] use
+        * copyin()/copyout() which will fail on kernel addresses.
+        *
+        * So, we must duplicate code from sys_ioctl() and ifconf().  Ugh.
+        */
+
+       fdp = p->p_fd;
+       if (fd >= fdp->fd_nfiles ||
+           (fp = fdp->fd_ofiles[fd]) == NULL ||
+           (fp->f_iflags & FIF_WANTCLOSE) != 0)
+               return (EBADF);
+
+       FILE_USE(fp);
+       if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
+               error = EBADF;
+               goto out;
+       }
+
+       error = copyin(data, (caddr_t)&lreq, sizeof(lreq));
+       if (error)
+               goto out;
+       lreq.if_name[IF_NAME_LEN-1] = '\0';             /* just in case */
+
+       /*
+        * Only support finding addresses for "ethX".  Should we
+        * do otherwise? XXX
+        */
+       if (lreq.if_name[0] == 'e' &&
+           lreq.if_name[1] == 't' &&
+           lreq.if_name[2] == 'h') {
+               for (ifnum = 0, index = 3;
+                    lreq.if_name[index] != '\0' && index < IF_NAME_LEN;
+                    index++) {
+                       ifnum *= 10;
+                       ifnum += lreq.if_name[index] - '0';
+               }
+
+               error = EINVAL;                 /* in case we don't find one */
+               for (ifp = ifnet.tqh_first, found = 0;
+                    ifp != 0 && !found;
+                    ifp = ifp->if_list.tqe_next) {
+                       memcpy(lreq.if_name, ifp->if_xname,
+                              MIN(IF_NAME_LEN, IFNAMSIZ));
+                       if ((ifa = ifp->if_addrlist.tqh_first) == 0)
+                               /* no addresses on this interface */
+                               continue;
+                       else 
+                               for (; ifa != 0; ifa = ifa->ifa_list.tqe_next) {
+                                       sadl = (struct sockaddr_dl *)ifa->ifa_addr;
+                                       /* only return ethernet addresses */
+                                       /* XXX what about FDDI, etc. ? */
+                                       if (sadl->sdl_family != AF_LINK ||
+                                           sadl->sdl_type != IFT_ETHER)
+                                               continue;
+                                       if (ifnum--)
+                                               /* not the reqested iface */
+                                               continue;
+                                       memcpy((caddr_t)&lreq.hwaddr.sa_data,
+                                              LLADDR(sadl),
+                                              MIN(sadl->sdl_alen,
+                                                  sizeof(lreq.hwaddr.sa_data)));
+                                       lreq.hwaddr.sa_family =
+                                               sadl->sdl_family;
+                                       error = copyout((caddr_t)&lreq, data,
+                                                       sizeof(lreq));
+                                       found = 1;
+                                       break;
+                               }
+               }
+       } else
+               /* not an "eth*" name */
+               error = EINVAL;
+    
+out:
+       FILE_UNUSE(fp, p);
+       return error;
+}
+#undef IF_NAME_LEN 16
+
 int
 linux_ioctl_socket(p, uap, retval)
        register struct proc *p;
@@ -483,6 +596,9 @@
        case LINUX_SIOCDELMULTI:
                SCARG(&ia, com) = SIOCDELMULTI;
                break;
+       case LINUX_SIOCGIFHWADDR:
+               return linux_getifhwaddr(p, retval, SCARG(uap, fd),
+                                        SCARG(uap, data));
        default:
                return EINVAL;
        }
diff -r 8c978f3a0524 -r 99202d7cc9c7 sys/compat/linux/common/linux_sockio.h
--- a/sys/compat/linux/common/linux_sockio.h    Mon Aug 02 21:51:41 1999 +0000
+++ b/sys/compat/linux/common/linux_sockio.h    Mon Aug 02 21:52:20 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_sockio.h,v 1.8 1998/10/04 00:02:44 fvdl Exp $    */
+/*     $NetBSD: linux_sockio.h,v 1.8.8.1 1999/08/02 21:52:21 thorpej Exp $     */
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -47,5 +47,6 @@
 #define        LINUX_SIOCGIFNETMASK    _LINUX_IO(0x89, 0x1b)
 #define LINUX_SIOCADDMULTI     _LINUX_IO(0x89, 0x31)
 #define LINUX_SIOCDELMULTI     _LINUX_IO(0x89, 0x32)
+#define LINUX_SIOCGIFHWADDR    _LINUX_IO(0x89, 0x27)
 
 #endif /* !_LINUX_SOCKIO_H */
diff -r 8c978f3a0524 -r 99202d7cc9c7 sys/compat/netbsd32/netbsd32_netbsd.c
--- a/sys/compat/netbsd32/netbsd32_netbsd.c     Mon Aug 02 21:51:41 1999 +0000
+++ b/sys/compat/netbsd32/netbsd32_netbsd.c     Mon Aug 02 21:52:20 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_netbsd.c,v 1.11.4.1 1999/06/21 01:08:08 thorpej Exp $ */
+/*     $NetBSD: netbsd32_netbsd.c,v 1.11.4.2 1999/08/02 21:52:57 thorpej Exp $ */
 
 /*
  * Copyright (c) 1998 Matthew R. Green
@@ -748,12 +748,6 @@
                        if (p->p_textvp)
                                vrele(p->p_textvp);
 
-                       /*
-                        * Give machine-dependent layer a chance
-                        * to free anything that cpu_exit couldn't
-                        * release while still running in process context.
-                        */
-                       cpu_wait(p);
                        pool_put(&proc_pool, p);
                        nprocs--;
                        return (0);
diff -r 8c978f3a0524 -r 99202d7cc9c7 sys/compat/netbsd32/syscalls.master
--- a/sys/compat/netbsd32/syscalls.master       Mon Aug 02 21:51:41 1999 +0000
+++ b/sys/compat/netbsd32/syscalls.master       Mon Aug 02 21:52:20 1999 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.7.4.1 1999/06/21 01:08:09 thorpej Exp $
+       $NetBSD: syscalls.master,v 1.7.4.2 1999/08/02 21:52:57 thorpej Exp $
 
 ;      from: NetBSD: syscalls.master,v 1.81 1998/07/05 08:49:50 jonathan Exp
 ;      @(#)syscalls.master     8.2 (Berkeley) 1/13/94
@@ -139,7 +139,7 @@
 66     NOARGS          { int sys_vfork(void); }
 67     OBSOL           vread
 68     OBSOL           vwrite
-69     STD             { int compat_netbsd32_sbrk(int incr); }
+69     STD             { int compat_netbsd32_sbrk(netbsd32_intptr_t incr); }
 70     STD             { int compat_netbsd32_sstk(int incr); }
 71     COMPAT_43       { int compat_netbsd32_ommap(netbsd32_caddr_t addr, netbsd32_size_t len, int prot, int flags, int fd, netbsd32_long pos); }
 72     STD             { int compat_netbsd32_ovadvise(int anom); } vadvise



Home | Main Index | Thread Index | Old Index