glibc/sysdeps/mach
Sergey Bugaev 27cb2bb93d hurd: Implement MAP_EXCL
MAP_FIXED is defined to silently replace any existing mappings at the
address range being mapped over. This, however, is a dangerous, and only
rarely desired behavior.

Various Unix systems provide replacements or additions to MAP_FIXED:

* SerenityOS and Linux provide MAP_FIXED_NOREPLACE. If the address space
  already contains a mapping in the requested range, Linux returns
  EEXIST. SerenityOS returns ENOMEM, however that is a bug, as the
  MAP_FIXED_NOREPLACE implementation is intended to be compatible with
  Linux.

* FreeBSD provides the MAP_EXCL flag that has to be used in combination
  with MAP_FIXED. It returns EINVAL if the requested range already
  contains existing mappings. This is directly analogous to the O_EXCL
  flag in the open () call.

* DragonFly BSD, NetBSD, and OpenBSD provide MAP_TRYFIXED, but with
  different semantics. DragonFly BSD returns ENOMEM if the requested
  range already contains existing mappings. NetBSD does not return an
  error, but instead creates the mapping at a different address if the
  requested range contains mappings. OpenBSD behaves the same, but also
  notes that this is the default behavior even without MAP_TRYFIXED
  (which is the case on the Hurd too).

Since the Hurd leans closer to the BSD side, add MAP_EXCL as the primary
API to request the behavior of not replacing existing mappings. Declare
MAP_FIXED_NOREPLACE and MAP_TRYFIXED as aliases of (MAP_FIXED|MAP_EXCL),
so any existing software that checks for either of those macros will
pick them up automatically. For compatibility with Linux, return EEXIST
if a mapping already exists.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230625231751.404120-5-bugaevc@gmail.com>
2023-07-03 01:38:14 +02:00
..
htl htl: Let Mach place thread stacks 2023-07-03 01:25:33 +02:00
hurd hurd: Implement MAP_EXCL 2023-07-03 01:38:14 +02:00
i386 Define PC, SP and SYSRETURN for hurd x86_64 2023-02-20 01:33:15 +01:00
include Define __mig_strlen to support dynamically sized strings in hurd RPCs 2023-05-01 02:24:04 +02:00
sys Installed-header hygiene (BZ#20366): obsolete BSD u_* types. 2016-09-23 08:43:56 -04:00
x86 mach: Define MACHINE_THREAD_STATE_SETUP_CALL 2023-05-17 22:52:39 +02:00
x86_64 hurd: Set up the basic tree for x86_64-gnu 2023-02-12 16:12:06 +01:00
_strerror.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
adjtime.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
clock_gettime.c hurd: Fix __TIMESIZE on x86_64 2023-05-19 20:25:37 +02:00
clock_nanosleep.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
configure mach: Fix installing mach_i386.h 2023-05-23 01:47:05 +02:00
configure.ac mach: Fix installing mach_i386.h 2023-05-23 01:47:05 +02:00
getloadavg.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
getpagesize.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
getsysstats.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
libc-lock.h mach, hurd: Drop __libc_lock_self0 2023-04-03 01:02:44 +02:00
libmachuser.abilist hurd: add base abilist files 2018-01-28 17:26:35 +01:00
mach_rpc.h Update hurd/hurdselect.c to be more portable. 2023-05-06 23:10:55 +02:00
Makefile Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
mprotect.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
msync.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
munmap.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
pagecopy.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
readonly-area.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
sched_yield.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
sleep.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strerror_l.c mach: strerror must not return NULL (bug 30555) 2023-07-02 11:27:51 +00:00
Subdirs * Makefile (subdir-target-args): New variable. 2006-02-28 07:11:04 +00:00
sysdep.h hurd: Remove __hurd_local_reply_port 2023-04-14 10:31:22 +00:00
thread_state.h mach: Define MACHINE_THREAD_STATE_SETUP_CALL 2023-05-17 22:52:39 +02:00
usleep.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
xpg-strerror.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00