Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/freebsd Add a good enuf emulation of the MAP_STAC...
details: https://anonhg.NetBSD.org/src/rev/1025de8abbaf
branches: trunk
changeset: 552091:1025de8abbaf
user: pooka <pooka%NetBSD.org@localhost>
date: Thu Sep 18 14:44:09 2003 +0000
description:
Add a good enuf emulation of the MAP_STACK flag to the mmap()
syscall. This allows programs which use MAP_STACK to work instead
of failing in weird and wonderous ways.
diffstat:
sys/compat/freebsd/freebsd_misc.c | 59 ++++++++++++++++++++++++++++++++++++-
sys/compat/freebsd/freebsd_mman.h | 42 +++++++++++++++++++++++++++
sys/compat/freebsd/syscalls.master | 6 +-
3 files changed, 102 insertions(+), 5 deletions(-)
diffs (160 lines):
diff -r b49ae99bbb71 -r 1025de8abbaf sys/compat/freebsd/freebsd_misc.c
--- a/sys/compat/freebsd/freebsd_misc.c Thu Sep 18 13:48:05 2003 +0000
+++ b/sys/compat/freebsd/freebsd_misc.c Thu Sep 18 14:44:09 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: freebsd_misc.c,v 1.19 2003/06/29 22:29:16 fvdl Exp $ */
+/* $NetBSD: freebsd_misc.c,v 1.20 2003/09/18 14:44:09 pooka Exp $ */
/*
* Copyright (c) 1995 Frank van der Linden
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: freebsd_misc.c,v 1.19 2003/06/29 22:29:16 fvdl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: freebsd_misc.c,v 1.20 2003/09/18 14:44:09 pooka Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ntp.h"
@@ -50,6 +50,7 @@
#include <sys/signal.h>
#include <sys/signalvar.h>
#include <sys/malloc.h>
+#include <sys/mman.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
@@ -62,6 +63,7 @@
#include <compat/freebsd/freebsd_rtprio.h>
#include <compat/freebsd/freebsd_timex.h>
#include <compat/freebsd/freebsd_signal.h>
+#include <compat/freebsd/freebsd_mman.h>
int
freebsd_sys_msync(l, v, retval)
@@ -87,6 +89,59 @@
return sys___msync13(l, &bma, retval);
}
+int
+freebsd_sys_mmap(l, v, retval)
+ struct lwp *l;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_mmap_args /* {
+ syscallarg(caddr_t) addr;
+ syscallarg(size_t) len;
+ syscallarg(int) prot;
+ syscallarg(int) flags;
+ syscallarg(int) fd;
+ syscallarg(long) pad;
+ syscallarg(off_t) pos;
+ } */ *uap = v;
+ struct sys_mmap_args bma;
+ int flags, prot, fd;
+ off_t pos;
+
+ prot = SCARG(uap, prot);
+ flags = SCARG(uap, flags);
+ fd = SCARG(uap, fd);
+ pos = SCARG(uap, pos);
+
+ /*
+ * If using MAP_STACK on FreeBSD:
+ *
+ * + fd has to be -1
+ * + prot must have read and write
+ * + MAP_STACK implies MAP_ANON
+ * + MAP_STACK implies offset of 0
+ */
+ if (flags & FREEBSD_MAP_STACK) {
+ if ((fd != -1)
+ ||((prot & (PROT_READ|PROT_WRITE))!=(PROT_READ|PROT_WRITE)))
+ return (EINVAL);
+
+ flags |= (MAP_ANON | MAP_FIXED);
+ flags &= ~FREEBSD_MAP_STACK;
+
+ pos = 0;
+ }
+
+ SCARG(&bma, addr) = SCARG(uap, addr);
+ SCARG(&bma, len) = SCARG(uap, len);
+ SCARG(&bma, prot) = prot;
+ SCARG(&bma, flags) = flags;
+ SCARG(&bma, fd) = fd;
+ SCARG(&bma, pos) = pos;
+
+ return sys_mmap(l, &bma, retval);
+}
+
/* just a place holder */
int
diff -r b49ae99bbb71 -r 1025de8abbaf sys/compat/freebsd/freebsd_mman.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/freebsd/freebsd_mman.h Thu Sep 18 14:44:09 2003 +0000
@@ -0,0 +1,42 @@
+/* $NetBSD: freebsd_mman.h,v 1.1 2003/09/18 14:44:10 pooka Exp $ */
+
+/*-
+ * Copyright (c) 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _FREEBSD_MMAN_H_
+#define _FREEBSD_MMAN_H_
+
+#define FREEBSD_MAP_STACK 0x0400
+#define FREEBSD_MAP_NOSYNC 0x0800
+
+#endif /* !_FREEBSD_MMAN_H_ */
diff -r b49ae99bbb71 -r 1025de8abbaf sys/compat/freebsd/syscalls.master
--- a/sys/compat/freebsd/syscalls.master Thu Sep 18 13:48:05 2003 +0000
+++ b/sys/compat/freebsd/syscalls.master Thu Sep 18 14:44:09 2003 +0000
@@ -1,4 +1,4 @@
- $NetBSD: syscalls.master,v 1.40 2003/01/18 07:33:16 thorpej Exp $
+ $NetBSD: syscalls.master,v 1.41 2003/09/18 14:44:09 pooka Exp $
; from: @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@@ -395,8 +395,8 @@
195 NOARGS { int sys_setrlimit(u_int which, struct rlimit *rlp); }
196 NOARGS { int compat_12_sys_getdirentries(int fd, char *buf, \
u_int count, long *basep); }
-197 NOARGS { caddr_t sys_mmap(caddr_t addr, size_t len, int prot, \
- int flags, int fd, long pad, off_t pos); }
+197 STD { caddr_t freebsd_sys_mmap(caddr_t addr, size_t len, \
+ int prot, int flags, int fd, long pad, off_t pos); }
198 NOARGS { int sys_nosys(void); } __syscall
199 NOARGS { off_t sys_lseek(int fd, int pad, off_t offset, \
int whence); }
Home |
Main Index |
Thread Index |
Old Index