diff options
author | Matthew Dempsky <matthew@cvs.openbsd.org> | 2014-06-27 20:50:44 +0000 |
---|---|---|
committer | Matthew Dempsky <matthew@cvs.openbsd.org> | 2014-06-27 20:50:44 +0000 |
commit | c32b75bffd068c180ad1fc053f192e902bbd4268 (patch) | |
tree | 1cf922f9aa9524f7b7b0c53373b838d689e3b7bc | |
parent | c562329cd851bf1c2fb400825f3e7e693ae688dd (diff) |
Cleanup support for legacy mmap flags
Move all legacy MAP_FOO values behind #ifndef _KERNEL and redefine
them to either be aliases for existing flags (e.g., MAP_COPY ->
MAP_PRIVATE) or 0.
Also, add MAP_OLDFOO defines (behind #ifndef _KERNEL) so the kernel
and kdump can remain compatible with current OpenBSD binaries.
ok deraadt
-rw-r--r-- | sys/sys/mman.h | 49 | ||||
-rw-r--r-- | sys/uvm/uvm_mmap.c | 6 | ||||
-rw-r--r-- | usr.bin/kdump/mksubr | 4 |
3 files changed, 39 insertions, 20 deletions
diff --git a/sys/sys/mman.h b/sys/sys/mman.h index 899fb7e8af3..c1c4664fdc7 100644 --- a/sys/sys/mman.h +++ b/sys/sys/mman.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mman.h,v 1.24 2014/06/13 01:48:52 matthew Exp $ */ +/* $OpenBSD: mman.h,v 1.25 2014/06/27 20:50:43 matthew Exp $ */ /* $NetBSD: mman.h,v 1.11 1995/03/26 20:24:23 jtc Exp $ */ /*- @@ -50,32 +50,49 @@ */ #define MAP_SHARED 0x0001 /* share changes */ #define MAP_PRIVATE 0x0002 /* changes are private */ -#define MAP_COPY 0x0004 /* "copy" region at mmap time */ /* * Other flags */ -#define MAP_FIXED 0x0010 /* map addr must be exactly as requested */ -#define MAP_RENAME 0x0020 /* Sun: rename private pages to file */ -#define MAP_NORESERVE 0x0040 /* Sun: don't reserve needed swap area */ -#define MAP_INHERIT 0x0080 /* region is retained after exec */ -#define MAP_NOEXTEND 0x0100 /* for MAP_FILE, don't change file size */ -#define MAP_HASSEMAPHORE 0x0200 /* region may contain semaphores */ -#define MAP_TRYFIXED 0x0400 /* attempt hint address, even within heap */ +#define MAP_FIXED 0x0010 /* map addr must be exactly as requested */ +#define __MAP_NOREPLACE 0x0800 /* fail if address not available */ +#define MAP_ANON 0x1000 /* allocated from memory, swap space */ -#define __MAP_NOREPLACE 0x0800 /* fail if address not available */ +#define MAP_FLAGMASK 0x1ff7 +#ifdef _KERNEL /* - * Error return from mmap() + * Backwards compat for OpenBSD 5.5. + * TODO: Remove after OpenBSD 5.7 release. */ -#define MAP_FAILED ((void *)-1) +#define MAP_OLDCOPY 0x0004 /* alias for MAP_PRIVATE */ +#define MAP_OLDRENAME 0x0020 +#define MAP_OLDNORESERVE 0x0040 +#define MAP_OLDINHERIT 0x0080 +#define MAP_OLDNOEXTEND 0x0100 +#define MAP_OLDHASSEMAPHORE 0x0200 +#define MAP_OLDTRYFIXED 0x0400 +#endif +#ifndef _KERNEL /* - * Mapping type + * Legacy defines for userland source compatibility. + * Can be removed once no longer needed in base and ports. */ -#define MAP_FILE 0x0000 /* map from file (default) */ -#define MAP_ANON 0x1000 /* allocated from memory, swap space */ -#define MAP_FLAGMASK 0x1ff7 +#define MAP_COPY MAP_PRIVATE /* "copy" region at mmap time */ +#define MAP_FILE 0 /* map from file (default) */ +#define MAP_HASSEMAPHORE 0 /* region may contain semaphores */ +#define MAP_INHERIT 0 /* region is retained after exec */ +#define MAP_NOEXTEND 0 /* for MAP_FILE, don't change file size */ +#define MAP_NORESERVE 0 /* Sun: don't reserve needed swap area */ +#define MAP_RENAME 0 /* Sun: rename private pages to file */ +#define MAP_TRYFIXED 0 /* attempt hint address, even within heap */ +#endif + +/* + * Error return from mmap() + */ +#define MAP_FAILED ((void *)-1) /* * POSIX memory advisory values. diff --git a/sys/uvm/uvm_mmap.c b/sys/uvm/uvm_mmap.c index d6d3899102c..bed8ef9a896 100644 --- a/sys/uvm/uvm_mmap.c +++ b/sys/uvm/uvm_mmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_mmap.c,v 1.94 2014/04/13 23:14:15 tedu Exp $ */ +/* $OpenBSD: uvm_mmap.c,v 1.95 2014/06/27 20:50:43 matthew Exp $ */ /* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */ /* @@ -345,8 +345,8 @@ sys_mmap(struct proc *p, void *v, register_t *retval) return (EINVAL); if ((flags & MAP_FLAGMASK) != flags) return (EINVAL); - if (flags & MAP_COPY) - flags = (flags & ~MAP_COPY) | MAP_PRIVATE; + if (flags & MAP_OLDCOPY) + flags = (flags & MAP_OLDCOPY) | MAP_PRIVATE; if ((flags & (MAP_SHARED|MAP_PRIVATE)) == (MAP_SHARED|MAP_PRIVATE)) return (EINVAL); if ((flags & (MAP_FIXED|__MAP_NOREPLACE)) == __MAP_NOREPLACE) diff --git a/usr.bin/kdump/mksubr b/usr.bin/kdump/mksubr index 56f91ea2240..b685a034eca 100644 --- a/usr.bin/kdump/mksubr +++ b/usr.bin/kdump/mksubr @@ -1,5 +1,5 @@ #!/bin/sh -# $OpenBSD: mksubr,v 1.18 2013/12/21 07:32:35 guenther Exp $ +# $OpenBSD: mksubr,v 1.19 2014/06/27 20:50:43 matthew Exp $ # # Copyright (c) 2006 David Kirchner <dpk@dpk.net> # @@ -241,7 +241,9 @@ cat <<_EOF_ #include <sys/fcntl.h> #include <sys/stat.h> #include <sys/unistd.h> +#define _KERNEL #include <sys/mman.h> +#undef _KERNEL #include <sys/wait.h> #include <sys/proc.h> #define _KERNEL |