Source-Changes-HG archive

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

[src/netbsd-1-6]: src/sys/compat/linux/common Pullup rev 1.118 (via patch) (r...



details:   https://anonhg.NetBSD.org/src/rev/964b26eb5571
branches:  netbsd-1-6
changeset: 530940:964b26eb5571
user:      jmc <jmc%NetBSD.org@localhost>
date:      Wed Oct 22 04:03:51 2003 +0000

description:
Pullup rev 1.118 (via patch) (requested by tv in ticket #1427)

Proper support for mmap2

diffstat:

 sys/compat/linux/common/linux_misc.c |  72 ++++++++++++++++++++++++++++-------
 1 files changed, 57 insertions(+), 15 deletions(-)

diffs (109 lines):

diff -r 268b31ae7193 -r 964b26eb5571 sys/compat/linux/common/linux_misc.c
--- a/sys/compat/linux/common/linux_misc.c      Wed Oct 22 04:03:00 2003 +0000
+++ b/sys/compat/linux/common/linux_misc.c      Wed Oct 22 04:03:51 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_misc.c,v 1.109.4.3 2003/10/22 03:47:43 jmc Exp $ */
+/*     $NetBSD: linux_misc.c,v 1.109.4.4 2003/10/22 04:03:51 jmc Exp $ */
 
 /*-
  * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.109.4.3 2003/10/22 03:47:43 jmc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.109.4.4 2003/10/22 04:03:51 jmc Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -169,6 +169,8 @@
 /* Local linux_misc.c functions: */
 static void bsd_to_linux_statfs __P((struct statfs *, struct linux_statfs *));
 static int linux_to_bsd_limit __P((int));
+static void linux_to_bsd_mmap_args __P((struct sys_mmap_args *,
+    const struct linux_sys_mmap_args *));
 
 /*
  * The information on a terminated (or stopped) process needs
@@ -444,28 +446,68 @@
                syscallarg(linux_off_t) offset;
        } */ *uap = v;
        struct sys_mmap_args cma;
-       int flags = 0, fl = SCARG(uap, flags);
-       
+
        if (SCARG(uap, offset) & PAGE_MASK)
                return EINVAL;
 
+       linux_to_bsd_mmap_args(&cma, uap);
+       SCARG(&cma, pos) = (off_t)SCARG(uap, offset);
+
+       return sys_mmap(p, &cma, retval);
+}
+
+/*
+ * Guts of most architectures' mmap64() implementations.  This shares
+ * its list of arguments with linux_sys_mmap().
+ *
+ * The difference in linux_sys_mmap2() is that "offset" is actually
+ * (offset / pagesize), not an absolute byte count.  This translation
+ * to pagesize offsets is done inside glibc between the mmap64() call
+ * point, and the actual syscall.
+ */
+int
+linux_sys_mmap2(p, v, retval)
+       struct proc *p;
+       void *v;
+       register_t *retval;
+{
+       struct linux_sys_mmap2_args /* {
+               syscallarg(unsigned long) addr;
+               syscallarg(size_t) len;
+               syscallarg(int) prot;
+               syscallarg(int) flags;
+               syscallarg(int) fd;
+               syscallarg(linux_off_t) offset;
+       } */ *uap = v;
+       struct sys_mmap_args cma;
+
+       linux_to_bsd_mmap_args(&cma, uap);
+       SCARG(&cma, pos) = ((off_t)SCARG(uap, offset)) << PAGE_SHIFT;
+
+       return sys_mmap(p, &cma, retval);
+}
+
+static void
+linux_to_bsd_mmap_args(cma, uap)
+       struct sys_mmap_args *cma;
+       const struct linux_sys_mmap_args *uap;
+{
+       int flags = 0, fl = SCARG(uap, flags);
+       
        flags |= cvtto_bsd_mask(fl, LINUX_MAP_SHARED, MAP_SHARED);
        flags |= cvtto_bsd_mask(fl, LINUX_MAP_PRIVATE, MAP_PRIVATE);
        flags |= cvtto_bsd_mask(fl, LINUX_MAP_FIXED, MAP_FIXED);
        flags |= cvtto_bsd_mask(fl, LINUX_MAP_ANON, MAP_ANON);
        /* XXX XAX ERH: Any other flags here?  There are more defined... */
 
-       SCARG(&cma, addr) = (void *)SCARG(uap, addr);
-       SCARG(&cma, len) = SCARG(uap, len);
-       SCARG(&cma, prot) = SCARG(uap, prot);
-       if (SCARG(&cma, prot) & VM_PROT_WRITE) /* XXX */
-               SCARG(&cma, prot) |= VM_PROT_READ;
-       SCARG(&cma, flags) = flags;
-       SCARG(&cma, fd) = flags & MAP_ANON ? -1 : SCARG(uap, fd);
-       SCARG(&cma, pad) = 0;
-       SCARG(&cma, pos) = (off_t)SCARG(uap, offset);
-
-       return sys_mmap(p, &cma, retval);
+       SCARG(cma, addr) = (void *)SCARG(uap, addr);
+       SCARG(cma, len) = SCARG(uap, len);
+       SCARG(cma, prot) = SCARG(uap, prot);
+       if (SCARG(cma, prot) & VM_PROT_WRITE) /* XXX */
+               SCARG(cma, prot) |= VM_PROT_READ;
+       SCARG(cma, flags) = flags;
+       SCARG(cma, fd) = flags & MAP_ANON ? -1 : SCARG(uap, fd);
+       SCARG(cma, pad) = 0;
 }
 
 int



Home | Main Index | Thread Index | Old Index