[patch] document that O_TMPFILE works with shm_open

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This test program works fine. (Watch it work in strace.) This patch is
against git master. It's okay to document accidental features, right?

int
main()
{
    int shmfd = shm_open(".", O_TMPFILE | O_RDWR | O_EXCL, 0600);
    ftruncate(shmfd, 1000);
    mmap(NULL, 1000, PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, 0);

    return 0;
}


diff --git a/man3/shm_open.3 b/man3/shm_open.3
index 6b04f39..7b9b7c3 100644
--- a/man3/shm_open.3
+++ b/man3/shm_open.3
@@ -116,6 +116,32 @@ object can be set using
 The newly allocated bytes of a shared memory
 object are automatically initialized to 0.
 .TP
+.BR O_TMPFILE " (since Linux 3.11)"
+.BR shm_open ()
+can be used to create an anonymous shared memory region by using exactly
+the string "." as
+.I name
+and including both
+.B O_TMPFILE
+and
+.B O_EXCL
+in
+.I oflag
+while omitting
+.B O_CREAT
+.
+Shared memory regions created this way work just like ones created without
+.B O_TMPFILE
+and with
+.B O_CREAT
+except that they are automatically released and their contents
discarded when the
+last reference to the
+region disappears.  References are either
+.BR mmap (2)
+mappings or file descriptors.
+See also
+.BR memfd_create (2).
+.TP
 .B O_EXCL
 If
 .B O_CREAT
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux