summaryrefslogtreecommitdiffstats
path: root/tests/memory/memfd_create/t_memfd_create.c
diff options
context:
space:
mode:
authorThorsten Leemhuis <fedora@leemhuis.info>2019-12-05 00:33:21 +0100
committerThorsten Leemhuis <fedora@leemhuis.info>2019-12-05 00:34:15 +0100
commit91b06924d96afcf0f1d0e9c547eb15f01c78fffb (patch)
tree40017dfdc10bbf6ee55a5affce794af3e587263c /tests/memory/memfd_create/t_memfd_create.c
parent2adce5aeb6c95194af74c43c1598563c4748823a (diff)
parent6b45f47575b44ead23d61138c8f080fbb9f81f80 (diff)
downloadkernel-91b06924d96afcf0f1d0e9c547eb15f01c78fffb.tar.gz
kernel-91b06924d96afcf0f1d0e9c547eb15f01c78fffb.tar.xz
kernel-91b06924d96afcf0f1d0e9c547eb15f01c78fffb.zip
Diffstat (limited to 'tests/memory/memfd_create/t_memfd_create.c')
-rw-r--r--tests/memory/memfd_create/t_memfd_create.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/tests/memory/memfd_create/t_memfd_create.c b/tests/memory/memfd_create/t_memfd_create.c
index 73d641a6e..4250d7174 100644
--- a/tests/memory/memfd_create/t_memfd_create.c
+++ b/tests/memory/memfd_create/t_memfd_create.c
@@ -16,11 +16,12 @@
*
*/
-#include <linux/memfd.h>
-#include <linux/fcntl.h>
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
#include <sys/syscall.h>
#include <stdlib.h>
-#include <unistd.h>
#include <string.h>
#include <stdio.h>
@@ -66,10 +67,6 @@ int main(int argc, char *argv[])
if (write(fd, message, strlen(message)) <= 0)
errExit("write");
- //printf("PID: %ld; fd: %d; /proc/%ld/fd/%d\n",
- // (long) getpid(), fd, (long) getpid(), fd);
- printf("/proc/%ld/fd/%d\n", (long) getpid(), fd);
-
/* Code to map the file and populate the mapping with data
omitted */
@@ -92,6 +89,13 @@ int main(int argc, char *argv[])
errExit("fcntl");
}
+ /* Output the pathname of (a symbolic link to) the file
+ created by memfd_create() */
+
+ printf("/proc/%ld/fd/%d\n", (long) getpid(), fd);
+
+ fflush(stdout);
+
/* Keep running, so that the file created by memfd_create()
continues to exist */