Mirror of strace – the linux syscall tracer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ioprio.c 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
  3. * Copyright (c) 2014-2018 The strace developers.
  4. * All rights reserved.
  5. *
  6. * SPDX-License-Identifier: LGPL-2.1-or-later
  7. */
  8. #include "defs.h"
  9. #include "xstring.h"
  10. #include "xlat/ioprio_who.h"
  11. #include "xlat/ioprio_class.h"
  12. #define IOPRIO_CLASS_SHIFT (13)
  13. #define IOPRIO_PRIO_MASK ((1ul << IOPRIO_CLASS_SHIFT) - 1)
  14. #define IOPRIO_PRIO_CLASS(mask) ((mask) >> IOPRIO_CLASS_SHIFT)
  15. #define IOPRIO_PRIO_DATA(mask) ((mask) & IOPRIO_PRIO_MASK)
  16. static const char *
  17. sprint_ioprio(unsigned int ioprio)
  18. {
  19. static char outstr[256];
  20. char class_buf[64];
  21. unsigned int class, data;
  22. class = IOPRIO_PRIO_CLASS(ioprio);
  23. data = IOPRIO_PRIO_DATA(ioprio);
  24. sprintxval(class_buf, sizeof(class_buf), ioprio_class, class,
  25. "IOPRIO_CLASS_???");
  26. xsprintf(outstr, "IOPRIO_PRIO_VALUE(%s, %d)", class_buf, data);
  27. return outstr;
  28. }
  29. SYS_FUNC(ioprio_get)
  30. {
  31. if (entering(tcp)) {
  32. /* int which */
  33. printxval(ioprio_who, tcp->u_arg[0], "IOPRIO_WHO_???");
  34. /* int who */
  35. tprintf(", %d", (int) tcp->u_arg[1]);
  36. return 0;
  37. } else {
  38. if (syserror(tcp))
  39. return 0;
  40. if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW)
  41. tcp->auxstr = NULL;
  42. else
  43. tcp->auxstr = sprint_ioprio(tcp->u_rval);
  44. return RVAL_STR;
  45. }
  46. }
  47. SYS_FUNC(ioprio_set)
  48. {
  49. /* int which */
  50. printxval(ioprio_who, tcp->u_arg[0], "IOPRIO_WHO_???");
  51. /* int who */
  52. tprintf(", %d, ", (int) tcp->u_arg[1]);
  53. /* int ioprio */
  54. if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV)
  55. tprintf("%d", (int) tcp->u_arg[2]);
  56. if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW)
  57. return RVAL_DECODED;
  58. (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE
  59. ? tprints_comment : tprints)(sprint_ioprio(tcp->u_arg[2]));
  60. return RVAL_DECODED;
  61. }