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.

random_ioctl.c 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (c) 2018 The strace developers.
  3. * All rights reserved.
  4. *
  5. * SPDX-License-Identifier: LGPL-2.1-or-later
  6. */
  7. #include "defs.h"
  8. #include "print_fields.h"
  9. #include <linux/types.h>
  10. #include <linux/random.h>
  11. #define XLAT_MACROS_ONLY
  12. #include "xlat/random_ioctl_cmds.h"
  13. #undef XLAT_MACROS_ONLY
  14. /*
  15. * RNDGETPOOL was removed in 2.6.9, so non-ancient kernels always
  16. * return -EINVAL for that.
  17. */
  18. int
  19. random_ioctl(struct tcb *const tcp, const unsigned int code,
  20. const kernel_ulong_t arg)
  21. {
  22. struct rand_pool_info info;
  23. kernel_ulong_t buf;
  24. switch (code) {
  25. case RNDGETENTCNT:
  26. if (entering(tcp))
  27. return 0;
  28. ATTRIBUTE_FALLTHROUGH;
  29. case RNDADDTOENTCNT:
  30. tprints(", ");
  31. printnum_int(tcp, arg, "%d");
  32. break;
  33. case RNDADDENTROPY:
  34. tprints(", ");
  35. if (!umove_or_printaddr(tcp, arg, &info)) {
  36. PRINT_FIELD_D("{", info, entropy_count);
  37. PRINT_FIELD_D(", ", info, buf_size);
  38. tprints(", buf=");
  39. buf = arg + offsetof(struct rand_pool_info, buf);
  40. printstrn(tcp, buf, info.buf_size);
  41. tprints("}");
  42. }
  43. break;
  44. /* ioctls with no parameters */
  45. case RNDZAPENTCNT:
  46. case RNDCLEARPOOL:
  47. case RNDRESEEDCRNG:
  48. break;
  49. default:
  50. return RVAL_DECODED;
  51. }
  52. return RVAL_IOCTL_DECODED;
  53. }