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_mmsghdr.c 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_mmsghdr)
  9. #include "msghdr.h"
  10. typedef struct mmsghdr struct_mmsghdr;
  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_mmsghdr,
  20. struct tcb *const tcp, const kernel_ulong_t addr,
  21. void *const p)
  22. {
  23. struct mmsghdr *p_native = p;
  24. struct_mmsghdr 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_hdr.msg_name = (void *) (unsigned long)
  30. v_compat.msg_hdr.msg_name;
  31. p_native->msg_hdr.msg_namelen =
  32. v_compat.msg_hdr.msg_namelen;
  33. p_native->msg_hdr.msg_iov = (void *) (unsigned long)
  34. v_compat.msg_hdr.msg_iov;
  35. p_native->msg_hdr.msg_iovlen =
  36. v_compat.msg_hdr.msg_iovlen;
  37. p_native->msg_hdr.msg_control = (void *) (unsigned long)
  38. v_compat.msg_hdr.msg_control;
  39. p_native->msg_hdr.msg_controllen =
  40. v_compat.msg_hdr.msg_controllen;
  41. p_native->msg_hdr.msg_flags =
  42. v_compat.msg_hdr.msg_flags;
  43. p_native->msg_len =
  44. v_compat.msg_len;
  45. return sizeof(v_compat);
  46. }
  47. MPERS_PRINTER_DECL(unsigned int, sizeof_struct_mmsghdr, void)
  48. {
  49. return sizeof(struct_mmsghdr);
  50. }