POSIX_TYPED_MEM_OPEN(3P)
π posix_typed_mem_open π β POSIX Programmer's Manual, section 3P
okay bestie, so this page lives in the POSIX Programmer's Manual (that's the manual name, we're folding it in up top, you're welcome) β¨
πΈ PROLOG πΈ
Real talk: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (pls consult the corresponding Linux manual page for details on Linux behavior, iykyk), or β and this is the messy part β the interface may just not be implemented on Linux at all. π
π NAME π
posix_typed_mem_open β open a typed memory object (ADVANCED REALTIME)
π¦ SYNOPSIS π¦
#include <sys/mman.h>
int posix_typed_mem_open(const char *name, int oflag, int tflag);
β¨ DESCRIPTION β¨
So posix_typed_mem_open() establishes a connection between the typed memory object that the string pointed to by name is pointing at, and a file descriptor. It shall create an open file description that refers to the typed memory object, plus a file descriptor that refers to that open file description. The file descriptor shall be allocated as described in Section 2.14, File Descriptor Allocation, and other functions can use it to refer to that typed memory object. π«Ά
It is unspecified whether name appears in the file system and is visible to other functions that take pathnames as arguments. The name argument conforms to the construction rules for a pathname, except that:
- the interpretation of
<slash>characters other than the leading<slash>character innameis implementation-defined, and - the length limits for the
nameargument are implementation-defined and need not be the same as the pathname limits{PATH_MAX}and{NAME_MAX}.
If name begins with the <slash> character, then processes calling posix_typed_mem_open() with the same value of name shall refer to the same typed memory object. If name does not begin with the <slash> character, the effect is implementation-defined. π
Each typed memory object supported in a system shall be identified by a name which specifies not only its associated typed memory pool, but also the path or port by which it is accessed. Translation: the same typed memory pool accessed via several different ports shall have several different corresponding names. The binding between names and typed memory objects is established in an implementation-defined manner. And unlike shared memory objects, there is no way within POSIX.1β2008 for a program to create a typed memory object. Not even a little one. π
π the tflag flags π
The value of tflag shall determine how the typed memory object behaves when it's subsequently mapped by calls to mmap(). At most, one of the following flags defined in <sys/mman.h> may be specified:
POSIX_TYPED_MEM_ALLOCATEβ Allocate onmmap().POSIX_TYPED_MEM_ALLOCATE_CONTIGβ Allocate contiguously onmmap().POSIX_TYPED_MEM_MAP_ALLOCATABLEβ Map onmmap(), without affecting allocatability.
π§ what each one actually does π§
If tflag has the flag POSIX_TYPED_MEM_ALLOCATE specified, any subsequent call to mmap() using the returned file descriptor shall result in allocation and mapping of typed memory from the specified typed memory pool. The allocated memory may be a contiguous previously unallocated area of the typed memory pool, or several non-contiguous previously unallocated areas (mapped to a contiguous portion of the process address space). π
If tflag has the flag POSIX_TYPED_MEM_ALLOCATE_CONTIG specified, any subsequent call to mmap() using the returned file descriptor shall result in allocation and mapping of a single contiguous previously unallocated area of the typed memory pool (also mapped to a contiguous portion of the process address space).
If tflag has none of the flags POSIX_TYPED_MEM_ALLOCATE or POSIX_TYPED_MEM_ALLOCATE_CONTIG specified, any subsequent call to mmap() using the returned file descriptor shall map an application-chosen area from the specified typed memory pool such that this mapped area becomes unavailable for allocation until it's unmapped by all processes. π
If tflag has the flag POSIX_TYPED_MEM_MAP_ALLOCATABLE specified, any subsequent call to mmap() using the returned file descriptor shall map an application-chosen area from the specified typed memory pool without an effect on the availability of that area for allocation. That is: mapping such an object leaves each byte of the mapped area unallocated if it was unallocated prior to the mapping, or allocated if it was allocated prior to the mapping. Appropriate privileges to specify the POSIX_TYPED_MEM_MAP_ALLOCATABLE flag are implementation-defined. π
π the file descriptor vibes π
If successful, posix_typed_mem_open() shall return a file descriptor for the typed memory object. The open file description is new, and therefore the file descriptor shall not share it with any other processes. It is unspecified whether the file offset is set. The FD_CLOEXEC file descriptor flag associated with the new file descriptor shall be cleared.
Heads up bestie: the behavior ofmsync(),ftruncate(), and all file operations other thanmmap(),posix_mem_offset(),posix_typed_mem_get_info(),fstat(),dup(),dup2(), andclose()is unspecified when passed a file descriptor connected to a typed memory object by this function. So likeβ¦ don't. π«
π the access modes π
The file status flags of the open file description shall be set according to the value of oflag. Applications shall specify exactly one of the three access mode values described below and defined in the <fcntl.h> header, as the value of oflag:
O_RDONLYβ Open for read access only.O_WRONLYβ Open for write access only.O_RDWRβ Open for read or write access.
π« RETURN VALUE π«
Upon successful completion, the posix_typed_mem_open() function shall return a non-negative integer representing the file descriptor. Otherwise, it shall return -1 and set errno to indicate the error. Periodt.
π₯ ERRORS π₯
The posix_typed_mem_open() function shall fail if:
EACCESβ The typed memory object exists and the permissions specified byoflagare denied.EINTRβ Theposix_typed_mem_open()operation was interrupted by a signal.EINVALβ The flags specified intflagare invalid (more than one ofPOSIX_TYPED_MEM_ALLOCATE,POSIX_TYPED_MEM_ALLOCATE_CONTIG, orPOSIX_TYPED_MEM_MAP_ALLOCATABLEis specified).EMFILEβ All file descriptors available to the process are currently open.ENFILEβ Too many file descriptors are currently open in the system.ENOENTβ The named typed memory object does not exist.EPERMβ The caller lacks appropriate privileges to specify thePOSIX_TYPED_MEM_MAP_ALLOCATABLEflag in thetflagargument.
The posix_typed_mem_open() function may fail if:
ENAMETOOLONGβ The length of thenameargument exceeds{_POSIX_PATH_MAX}on systems that do not support the XSI option, or exceeds{_XOPEN_PATH_MAX}on XSI systems, or has a pathname component that is longer than{_POSIX_NAME_MAX}on systems that do not support the XSI option, or longer than{_XOPEN_NAME_MAX}on XSI systems.
The following sections are informative. π«‘
πΈ EXAMPLES πΈ
None.
π¦ APPLICATION USAGE π¦
None.
β¨ RATIONALE β¨
None.
π FUTURE DIRECTIONS π
None.
π SEE ALSO π
- Section 2.14, File Descriptor Allocation
close()dup()execfcntl()fstat()ftruncate()mmap()msync()posix_mem_offset()posix_typed_mem_get_info()umask()- The Base Definitions volume of POSIX.1β2017,
<fcntl.h>,<sys_mman.h>
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie!! π
this one came to you courtesy of IEEE/The Open Group, 2017 β stay hydrated, go map some typed memory, and remember: at most one tflag flag. mwah π«Άβ¨
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms