From bdcfc9bdf7418063bc6c9744221ff85fe1c776ba Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Wed, 24 Oct 2018 21:44:45 +0200 Subject: fcntl: decode read/write hints commands Introduced by Linux commit v4.13-rc1~212^2~51. * xlat/fcntl_rw_hints.in: New file. * fcntl.c: Include "xlat/fcntl_rw_hints.h". (print_rwhint): New function. (print_fcntl) : New fcntl command handlers. * xlat/fcntlcmds.in (F_GET_RW_HINT, F_SET_RW_HINT, F_GET_FILE_RW_HINT, F_SET_FILE_RW_HINT): New constants. --- src/fcntl.c | 27 +++++++++++++++++++++++++++ src/xlat/fcntl_rw_hints.in | 7 +++++++ src/xlat/fcntlcmds.in | 4 ++++ 3 files changed, 38 insertions(+) create mode 100644 src/xlat/fcntl_rw_hints.in diff --git a/src/fcntl.c b/src/fcntl.c index 333a6b598..4f12d3982 100644 --- a/src/fcntl.c +++ b/src/fcntl.c @@ -27,6 +27,7 @@ #include "xlat/f_owner_types.h" #include "xlat/f_seals.h" +#include "xlat/fcntl_rw_hints.h" #include "xlat/fcntlcmds.h" #include "xlat/fdflags.h" #include "xlat/lockfcmds.h" @@ -113,6 +114,19 @@ print_owner_uids(struct tcb *const tcp, const kernel_ulong_t addr) tprint_array_end(); } +static void +print_rwhint(struct tcb *const tcp, const kernel_ulong_t addr) +{ + uint64_t hint; + + if (umove_or_printaddr(tcp, addr, &hint)) + return; + + tprint_indirect_begin(); + printxval(fcntl_rw_hints, hint, "RWH_WRITE_LIFE_???"); + tprint_indirect_end(); +} + static int print_fcntl(struct tcb *tcp) { @@ -170,6 +184,11 @@ print_fcntl(struct tcb *tcp) tprint_arg_next(); printsignal(tcp->u_arg[2]); break; + case F_SET_RW_HINT: + case F_SET_FILE_RW_HINT: + tprint_arg_next(); + print_rwhint(tcp, tcp->u_arg[2]); + break; case F_GETOWN: return RVAL_DECODED | ((int) tcp->u_rval < 0 ? RVAL_PGID : RVAL_TGID); @@ -215,6 +234,14 @@ print_fcntl(struct tcb *tcp) tcp->auxstr = sprintflags("seals ", f_seals, (kernel_ulong_t) tcp->u_rval); return RVAL_HEX | RVAL_STR; + case F_GET_RW_HINT: + case F_GET_FILE_RW_HINT: + if (entering(tcp)) { + tprint_arg_next(); + return 0; + } + print_rwhint(tcp, tcp->u_arg[2]); + break; case F_GETSIG: if (entering(tcp) || syserror(tcp) || tcp->u_rval == 0) return 0; diff --git a/src/xlat/fcntl_rw_hints.in b/src/xlat/fcntl_rw_hints.in new file mode 100644 index 000000000..a70d24cd0 --- /dev/null +++ b/src/xlat/fcntl_rw_hints.in @@ -0,0 +1,7 @@ +#value_indexed +RWH_WRITE_LIFE_NOT_SET 0 +RWH_WRITE_LIFE_NONE 1 +RWH_WRITE_LIFE_SHORT 2 +RWH_WRITE_LIFE_MEDIUM 3 +RWH_WRITE_LIFE_LONG 4 +RWH_WRITE_LIFE_EXTREME 5 diff --git a/src/xlat/fcntlcmds.in b/src/xlat/fcntlcmds.in index e2305b00f..c5e6f690e 100644 --- a/src/xlat/fcntlcmds.in +++ b/src/xlat/fcntlcmds.in @@ -29,3 +29,7 @@ F_SETPIPE_SZ F_GETPIPE_SZ F_ADD_SEALS F_GET_SEALS +F_GET_RW_HINT +F_SET_RW_HINT +F_GET_FILE_RW_HINT +F_SET_FILE_RW_HINT -- cgit v1.2.1