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.

fetch_struct_msghdr.c 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (c) 2016-2018 Dmitry V. Levin <ldv@altlinux.org>
  3. * All rights reserved.
  4. *
  5. * SPDX-License-Identifier: LGPL-2.1-or-later
  6. */
  7. #include "defs.h"
  8. #include DEF_MPERS_TYPE(struct_msghdr)
  9. #include "msghdr.h"
  10. typedef struct msghdr struct_msghdr;
  11. #include MPERS_DEFS
  12. /*
  13. * On success, return the number of fetched bytes.
  14. * On error, return 0;
  15. *
  16. * This function cannot use umove_or_printaddr because
  17. * it is called by dumpio and therefore cannot print anything.
  18. */
  19. MPERS_PRINTER_DECL(int, fetch_struct_msghdr,
  20. struct tcb *const tcp, const kernel_ulong_t addr,
  21. void *const p)
  22. {
  23. struct msghdr *const p_native = p;
  24. struct_msghdr v_compat;
  25. if (sizeof(*p_native) == sizeof(v_compat))
  26. return umove(tcp, addr, p_native) ? 0 : sizeof(*p_native);
  27. if (umove(tcp, addr, &v_compat))
  28. return 0;
  29. p_native->msg_name = (void *) (unsigned long)
  30. v_compat.msg_name;
  31. p_native->msg_namelen =
  32. v_compat.msg_namelen;
  33. p_native->msg_iov = (void *) (unsigned long)
  34. v_compat.msg_iov;
  35. p_native->msg_iovlen =
  36. v_compat.msg_iovlen;
  37. p_native->msg_control = (void *) (unsigned long)
  38. v_compat.msg_control;
  39. p_native->msg_controllen =
  40. v_compat.msg_controllen;
  41. p_native->msg_flags =
  42. v_compat.msg_flags;
  43. return sizeof(v_compat);
  44. }