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) <case F_SET_RW_HINT, case F_SET_FILE_RW_HINT, case
F_GET_RW_HINT, case F_GET_FILE_RW_HINT>: 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.
This commit is contained in:
Eugene Syromyatnikov 2018-10-24 21:44:45 +02:00
parent 48a84accf6
commit d1f4b528cb
3 changed files with 39 additions and 0 deletions

27
fcntl.c
View File

@ -34,6 +34,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"
@ -84,6 +85,19 @@ print_f_owner_ex(struct tcb *const tcp, const kernel_ulong_t addr)
tprintf(", pid=%d}", owner.pid);
}
static void
print_rwhint(struct tcb *const tcp, const kernel_ulong_t addr)
{
uint64_t hint;
if (umove_or_printaddr(tcp, addr, &hint))
return;
tprints("[");
printxval(fcntl_rw_hints, hint, "RWH_WRITE_LIFE_???");
tprints("]");
}
static int
print_fcntl(struct tcb *tcp)
{
@ -136,6 +150,11 @@ print_fcntl(struct tcb *tcp)
tprints(", ");
printsignal(tcp->u_arg[2]);
break;
case F_SET_RW_HINT:
case F_SET_FILE_RW_HINT:
tprints(", ");
print_rwhint(tcp, tcp->u_arg[2]);
break;
case F_GETOWN:
case F_GETPIPE_SZ:
break;
@ -179,6 +198,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)) {
tprints(", ");
return 0;
}
print_rwhint(tcp, tcp->u_arg[2]);
break;
case F_GETSIG:
if (entering(tcp) || syserror(tcp) || tcp->u_rval == 0)
return 0;

7
xlat/fcntl_rw_hints.in Normal file
View File

@ -0,0 +1,7 @@
#value_indexed
RWF_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

View File

@ -96,3 +96,8 @@ F_SETPIPE_SZ (1024 + 7)
F_GETPIPE_SZ (1024 + 8)
F_ADD_SEALS (1024 + 9)
F_GET_SEALS (1024 + 10)
F_GET_RW_HINT (1024 + 11)
F_SET_RW_HINT (1024 + 12)
F_GET_FILE_RW_HINT (1024 + 13)
F_SET_FILE_RW_HINT (1024 + 14)