]> granicus.if.org Git - strace/commitdiff
decode_open: print the mode argument when O_TMPFILE flag is set
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 20 Sep 2016 18:41:50 +0000 (18:41 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 20 Sep 2016 20:55:56 +0000 (20:55 +0000)
O_TMPFILE reqires the mode argument (just like O_CREAT), so print it.

* open.c (STRACE_O_TMPFILE): New macro.
(decode_open): Print the mode argument when O_TMPFILE flag is set.
* tests/open.c (main): Check it.
Fixes RH#1377846.

open.c
tests/open.c

diff --git a/open.c b/open.c
index b712a229c7735d37387cc2356405cf6f7971c7b7..6128fb00554c72602d03c2d7a247cbdc251a001a 100644 (file)
--- a/open.c
+++ b/open.c
@@ -115,6 +115,13 @@ tprint_open_modes(unsigned int flags)
        tprints(sprint_open_modes(flags) + sizeof("flags"));
 }
 
+#ifdef O_TMPFILE
+/* The kernel & C libraries often inline O_DIRECTORY. */
+# define STRACE_O_TMPFILE (O_TMPFILE & ~O_DIRECTORY)
+#else /* !O_TMPFILE */
+# define STRACE_O_TMPFILE 0
+#endif
+
 static int
 decode_open(struct tcb *tcp, int offset)
 {
@@ -122,7 +129,7 @@ decode_open(struct tcb *tcp, int offset)
        tprints(", ");
        /* flags */
        tprint_open_modes(tcp->u_arg[offset + 1]);
-       if (tcp->u_arg[offset + 1] & O_CREAT) {
+       if (tcp->u_arg[offset + 1] & (O_CREAT | STRACE_O_TMPFILE)) {
                /* mode */
                tprints(", ");
                print_numeric_umode_t(tcp->u_arg[offset + 2]);
index 8987c5bf184cd6940dd4398b88ed56f30ac5b459..01e89b0f2c3703b0442d7281917e06dd60f0f152 100644 (file)
@@ -56,6 +56,17 @@ main(void)
                       sample, sprintrc(fd));
        }
 
+#ifdef O_TMPFILE
+# if O_TMPFILE == (O_TMPFILE & ~O_DIRECTORY)
+#  define STR_O_TMPFILE "O_TMPFILE"
+# else
+#  define STR_O_TMPFILE "O_DIRECTORY|O_TMPFILE"
+# endif
+       fd = syscall(__NR_open, sample, O_WRONLY|O_TMPFILE, 0600);
+       printf("open(\"%s\", O_WRONLY|%s, 0600) = %s\n",
+              sample, STR_O_TMPFILE, sprintrc(fd));
+#endif /* O_TMPFILE */
+
        puts("+++ exited with 0 +++");
        return 0;
 }