From: Dmitry V. Levin Date: Tue, 20 Sep 2016 18:41:50 +0000 (+0000) Subject: decode_open: print the mode argument when O_TMPFILE flag is set X-Git-Tag: v4.14~60 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=212a444bdc24cdc22622987a515197e69ad2a83f;p=strace decode_open: print the mode argument when O_TMPFILE flag is set 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. --- diff --git a/open.c b/open.c index b712a229..6128fb00 100644 --- 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]); diff --git a/tests/open.c b/tests/open.c index 8987c5bf..01e89b0f 100644 --- a/tests/open.c +++ b/tests/open.c @@ -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; }