From fc4727de60fa79b0f638a2c78a3edf865dc75943 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Wed, 5 Feb 2014 17:27:43 +0000 Subject: Implement ioprio_get and ioprio_set decoding * ioprio.c: New file. * Makefile.am (strace_SOURCES): Add ioprio.c. * linux/dummy.h (sys_ioprio_get, sys_ioprio_set): Remove. * linux/syscall.h (sys_ioprio_get, sys_ioprio_set): New prototypes. --- Makefile.am | 1 + ioprio.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ linux/dummy.h | 2 -- linux/syscall.h | 2 ++ 4 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 ioprio.c diff --git a/Makefile.am b/Makefile.am index 26869fb..65929dc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,6 +25,7 @@ strace_SOURCES = \ inotify.c \ io.c \ ioctl.c \ + ioprio.c \ ipc.c \ kexec.c \ loop.c \ diff --git a/ioprio.c b/ioprio.c new file mode 100644 index 0000000..52c5a28 --- /dev/null +++ b/ioprio.c @@ -0,0 +1,86 @@ +#include "defs.h" + +enum { + IOPRIO_WHO_PROCESS = 1, + IOPRIO_WHO_PGRP, + IOPRIO_WHO_USER +}; + +static const struct xlat ioprio_who[] = { + XLAT(IOPRIO_WHO_PROCESS), + XLAT(IOPRIO_WHO_PGRP), + XLAT(IOPRIO_WHO_USER), + XLAT_END +}; + +enum { + IOPRIO_CLASS_NONE, + IOPRIO_CLASS_RT, + IOPRIO_CLASS_BE, + IOPRIO_CLASS_IDLE +}; + +static const struct xlat ioprio_class[] = { + XLAT(IOPRIO_CLASS_NONE), + XLAT(IOPRIO_CLASS_RT), + XLAT(IOPRIO_CLASS_BE), + XLAT(IOPRIO_CLASS_IDLE), + XLAT_END +}; + +#define IOPRIO_CLASS_SHIFT (13) +#define IOPRIO_PRIO_MASK ((1ul << IOPRIO_CLASS_SHIFT) - 1) + +#define IOPRIO_PRIO_CLASS(mask) ((mask) >> IOPRIO_CLASS_SHIFT) +#define IOPRIO_PRIO_DATA(mask) ((mask) & IOPRIO_PRIO_MASK) + +static const char * +sprint_ioprio(int ioprio) +{ + static char outstr[256]; + const char *str; + int class, data; + + class = IOPRIO_PRIO_CLASS(ioprio); + data = IOPRIO_PRIO_DATA(ioprio); + str = xlookup(ioprio_class, class); + if (str) + sprintf(outstr, "IOPRIO_PRIO_VALUE(%s,%d)", str, data); + else + sprintf(outstr, "IOPRIO_PRIO_VALUE(%#x /* %s */,%d)", + class, "IOPRIO_CLASS_???", data); + + return outstr; +} + +int +sys_ioprio_get(struct tcb *tcp) +{ + if (entering(tcp)) { + /* int which */ + printxval(ioprio_who, tcp->u_arg[0], "IOPRIO_WHO_???"); + /* int who */ + tprintf(", %d", (int) tcp->u_arg[1]); + return 0; + } else { + if (syserror(tcp)) + return 0; + + tcp->auxstr = sprint_ioprio(tcp->u_rval); + return RVAL_STR; + } +} + +int +sys_ioprio_set(struct tcb *tcp) +{ + if (entering(tcp)) { + /* int which */ + printxval(ioprio_who, tcp->u_arg[0], "IOPRIO_WHO_???"); + /* int who */ + tprintf(", %d, ", (int) tcp->u_arg[1]); + /* int ioprio */ + tprints(sprint_ioprio(tcp->u_arg[2])); + } + return 0; +} diff --git a/linux/dummy.h b/linux/dummy.h index b9cd91b..2804499 100644 --- a/linux/dummy.h +++ b/linux/dummy.h @@ -35,8 +35,6 @@ #define sys_add_key printargs #define sys_ioperm printargs #define sys_iopl printargs -#define sys_ioprio_get printargs -#define sys_ioprio_set printargs #define sys_kcmp printargs #define sys_keyctl printargs #define sys_lookup_dcookie printargs diff --git a/linux/syscall.h b/linux/syscall.h index 17b9431..316113e 100644 --- a/linux/syscall.h +++ b/linux/syscall.h @@ -121,6 +121,8 @@ int sys_io_getevents(); int sys_io_setup(); int sys_io_submit(); int sys_ioctl(); +int sys_ioprio_get(); +int sys_ioprio_set(); int sys_ipc(); int sys_kexec_load(); int sys_kill(); -- cgit v1.2.3