Skip to content

Commit

Permalink
libc: remove shm_open(2)'s compat fallback
Browse files Browse the repository at this point in the history
This had been introduced to ease any pain for using slightly older kernels
with a newer libc, e.g., for bisecting a kernel across the introduction of
shm_open2(2). 6 months has passed, retire the fallback and let shm_open()
unconditionally call shm_open2().

Stale includes are removed as well.
  • Loading branch information
kevans91 committed Apr 13, 2020
1 parent 1c04eb2 commit 7c5e60c
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions lib/libc/sys/shm_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ __FBSDID("$FreeBSD$");

#include <sys/types.h>
#include <sys/mman.h>
#include <sys/syscall.h>

#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>

Expand All @@ -47,25 +45,13 @@ __FBSDID("$FreeBSD$");
__weak_reference(shm_open, _shm_open);
__weak_reference(shm_open, __sys_shm_open);

#define SHM_OPEN2_OSREL 1300048

#define MEMFD_NAME_PREFIX "memfd:"

int
shm_open(const char *path, int flags, mode_t mode)
{

if (__getosreldate() >= SHM_OPEN2_OSREL)
return (__sys_shm_open2(path, flags | O_CLOEXEC, mode, 0,
NULL));

/*
* Fallback to shm_open(2) on older kernels. The kernel will enforce
* O_CLOEXEC in this interface, unlike the newer shm_open2 which does
* not enforce it. The newer interface allows memfd_create(), for
* instance, to not have CLOEXEC on the returned fd.
*/
return (syscall(SYS_freebsd12_shm_open, path, flags, mode));
return (__sys_shm_open2(path, flags | O_CLOEXEC, mode, 0, NULL));
}

/*
Expand Down

0 comments on commit 7c5e60c

Please sign in to comment.