mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
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 <bugaevc@gmail.com> Message-Id: <20230130125216.6254-4-bugaevc@gmail.com>
This commit is contained in:
committed by
Samuel Thibault
parent
65392c8478
commit
a979b72747
@ -23,6 +23,7 @@
|
||||
#include <shlib-compat.h>
|
||||
#include <shm-directory.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
/* 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))
|
||||
|
Reference in New Issue
Block a user