|
|
619a20 |
diff -rup a/open.c b/open.c
|
|
|
619a20 |
--- a/open.c 2017-03-27 13:09:44.077819446 -0400
|
|
|
619a20 |
+++ b/open.c 2017-03-27 13:10:05.300586883 -0400
|
|
|
619a20 |
@@ -36,6 +36,10 @@
|
|
|
619a20 |
|
|
|
619a20 |
#include <fcntl.h>
|
|
|
619a20 |
|
|
|
619a20 |
+#ifndef O_TMPFILE
|
|
|
619a20 |
+#define O_TMPFILE 020000000
|
|
|
619a20 |
+#endif
|
|
|
619a20 |
+
|
|
|
619a20 |
#ifdef O_LARGEFILE
|
|
|
619a20 |
# if O_LARGEFILE == 0 /* biarch platforms in 64-bit mode */
|
|
|
619a20 |
# undef O_LARGEFILE
|
|
|
619a20 |
@@ -115,6 +119,13 @@ tprint_open_modes(unsigned int flags)
|
|
|
619a20 |
tprints(sprint_open_modes(flags) + sizeof("flags"));
|
|
|
619a20 |
}
|
|
|
619a20 |
|
|
|
619a20 |
+#ifdef O_TMPFILE
|
|
|
619a20 |
+/* The kernel & C libraries often inline O_DIRECTORY. */
|
|
|
619a20 |
+# define STRACE_O_TMPFILE (O_TMPFILE & ~O_DIRECTORY)
|
|
|
619a20 |
+#else /* !O_TMPFILE */
|
|
|
619a20 |
+# define STRACE_O_TMPFILE 0
|
|
|
619a20 |
+#endif
|
|
|
619a20 |
+
|
|
|
619a20 |
static int
|
|
|
619a20 |
decode_open(struct tcb *tcp, int offset)
|
|
|
619a20 |
{
|
|
|
619a20 |
@@ -122,7 +133,7 @@ decode_open(struct tcb *tcp, int offset)
|
|
|
619a20 |
tprints(", ");
|
|
|
619a20 |
/* flags */
|
|
|
619a20 |
tprint_open_modes(tcp->u_arg[offset + 1]);
|
|
|
619a20 |
- if (tcp->u_arg[offset + 1] & O_CREAT) {
|
|
|
619a20 |
+ if (tcp->u_arg[offset + 1] & (O_CREAT | STRACE_O_TMPFILE)) {
|
|
|
619a20 |
/* mode */
|
|
|
619a20 |
tprintf(", %#lo", tcp->u_arg[offset + 2]);
|
|
|
619a20 |
}
|
|
|
619a20 |
diff -rup a/tests/open.c b/tests/open.c
|
|
|
619a20 |
--- a/tests/open.c 2017-03-27 13:09:44.078819435 -0400
|
|
|
619a20 |
+++ b/tests/open.c 2017-03-27 13:31:55.843649714 -0400
|
|
|
619a20 |
@@ -59,6 +59,17 @@ main(void)
|
|
|
619a20 |
" = %d %s (%m)\n", sample, fd, errno2name());
|
|
|
619a20 |
}
|
|
|
619a20 |
|
|
|
619a20 |
+#ifdef O_TMPFILE
|
|
|
619a20 |
+# if O_TMPFILE == (O_TMPFILE & ~O_DIRECTORY)
|
|
|
619a20 |
+# define STR_O_TMPFILE "O_TMPFILE"
|
|
|
619a20 |
+# else
|
|
|
619a20 |
+# define STR_O_TMPFILE "O_DIRECTORY|O_TMPFILE"
|
|
|
619a20 |
+# endif
|
|
|
619a20 |
+ fd = syscall(__NR_open, sample, O_WRONLY|O_TMPFILE, 0600);
|
|
|
619a20 |
+ printf("open(\"%s\", O_WRONLY|%s, 0600) = %d %s (%m)\n",
|
|
|
619a20 |
+ sample, STR_O_TMPFILE, fd, errno2name());
|
|
|
619a20 |
+#endif /* O_TMPFILE */
|
|
|
619a20 |
+
|
|
|
619a20 |
puts("+++ exited with 0 +++");
|
|
|
619a20 |
return 0;
|
|
|
619a20 |
}
|