From a979b72747e34add3433a23c0966490cd809120f Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Mon, 30 Jan 2023 15:52:16 +0300 Subject: hurd: Implement SHM_ANON This adds a special SHM_ANON value that can be passed into shm_open () in place of a name. When called in this way, shm_open () will create a new anonymous shared memory file. The file will be created in the same way that other shared memory files are created (i.e., under /dev/shm/), except that it is not given a name and therefore cannot be reached from the file system, nor by other calls to shm_open (). This is accomplished by utilizing O_TMPFILE. This is intended to be compatible with FreeBSD's API of the same name. Signed-off-by: Sergey Bugaev Message-Id: <20230130125216.6254-4-bugaevc@gmail.com> --- rt/shm_open.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'rt') diff --git a/rt/shm_open.c b/rt/shm_open.c index 48970bbc81..6c1f4d604f 100644 --- a/rt/shm_open.c +++ b/rt/shm_open.c @@ -23,6 +23,7 @@ #include #include #include +#include /* Open shared memory object. */ int @@ -36,6 +37,10 @@ __shm_open (const char *name, int oflag, mode_t mode) } oflag |= O_NOFOLLOW | O_CLOEXEC; +#if defined (SHM_ANON) && defined (O_TMPFILE) + if (name == SHM_ANON) + oflag |= O_TMPFILE; +#endif int fd = __open64_nocancel (dirname.name, oflag, mode); if (fd == -1 && __glibc_unlikely (errno == EISDIR)) -- cgit 1.4.1