Skip to content

Commit

Permalink
decode_open: print the mode argument when O_TMPFILE flag is set
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ldv-alt committed Sep 20, 2016
1 parent 0918a4c commit 212a444
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 8 additions & 1 deletion open.c
Expand Up @@ -115,14 +115,21 @@ 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)
{
printpath(tcp, tcp->u_arg[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]);
Expand Down
11 changes: 11 additions & 0 deletions tests/open.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit 212a444

Please sign in to comment.