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.

ptp.c 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Copyright (c) 2014 Stefan Sørensen <stefan.sorensen@spectralink.com>
  3. * Copyright (c) 2014-2015 Dmitry V. Levin <ldv@altlinux.org>
  4. * Copyright (c) 2014-2018 The strace developers.
  5. * All rights reserved.
  6. *
  7. * SPDX-License-Identifier: LGPL-2.1-or-later
  8. */
  9. #include "defs.h"
  10. #ifdef HAVE_STRUCT_PTP_SYS_OFFSET
  11. # include <linux/ioctl.h>
  12. # include <linux/ptp_clock.h>
  13. # include "print_fields.h"
  14. # include "xlat/ptp_flags_options.h"
  15. int
  16. ptp_ioctl(struct tcb *const tcp, const unsigned int code,
  17. const kernel_ulong_t arg)
  18. {
  19. if (!verbose(tcp))
  20. return RVAL_DECODED;
  21. switch (code) {
  22. case PTP_EXTTS_REQUEST: {
  23. struct ptp_extts_request extts;
  24. tprints(", ");
  25. if (umove_or_printaddr(tcp, arg, &extts))
  26. break;
  27. PRINT_FIELD_D("{", extts, index);
  28. PRINT_FIELD_FLAGS(", ", extts, flags, ptp_flags_options, "PTP_???");
  29. tprints("}");
  30. break;
  31. }
  32. case PTP_PEROUT_REQUEST: {
  33. struct ptp_perout_request perout;
  34. tprints(", ");
  35. if (umove_or_printaddr(tcp, arg, &perout))
  36. break;
  37. PRINT_FIELD_D("{start={", perout.start, sec);
  38. PRINT_FIELD_U(", ", perout.start, nsec);
  39. PRINT_FIELD_D("}, period={", perout.period, sec);
  40. PRINT_FIELD_U(", ", perout.period, nsec);
  41. PRINT_FIELD_D("}, ", perout, index);
  42. PRINT_FIELD_FLAGS(", ", perout, flags, ptp_flags_options, "PTP_???");
  43. tprints("}");
  44. break;
  45. }
  46. case PTP_ENABLE_PPS:
  47. tprintf(", %" PRI_kld, arg);
  48. break;
  49. case PTP_SYS_OFFSET: {
  50. struct ptp_sys_offset sysoff;
  51. if (entering(tcp)) {
  52. tprints(", ");
  53. if (umove_or_printaddr(tcp, arg, &sysoff))
  54. break;
  55. PRINT_FIELD_U("{", sysoff, n_samples);
  56. return 0;
  57. } else {
  58. unsigned int n_samples, i;
  59. if (syserror(tcp)) {
  60. tprints("}");
  61. break;
  62. }
  63. tprints(", ");
  64. if (umove(tcp, arg, &sysoff) < 0) {
  65. tprints("???}");
  66. break;
  67. }
  68. tprints("ts=[");
  69. n_samples = sysoff.n_samples > PTP_MAX_SAMPLES ?
  70. PTP_MAX_SAMPLES : sysoff.n_samples;
  71. for (i = 0; i < 2 * n_samples + 1; ++i) {
  72. if (i > 0)
  73. tprints(", ");
  74. PRINT_FIELD_D("{", sysoff.ts[i], sec);
  75. PRINT_FIELD_U(", ", sysoff.ts[i], nsec);
  76. tprints("}");
  77. }
  78. if (sysoff.n_samples > PTP_MAX_SAMPLES)
  79. tprints(", ...");
  80. tprints("]}");
  81. break;
  82. }
  83. }
  84. case PTP_CLOCK_GETCAPS: {
  85. struct ptp_clock_caps caps;
  86. if (entering(tcp))
  87. return 0;
  88. tprints(", ");
  89. if (umove_or_printaddr(tcp, arg, &caps))
  90. break;
  91. PRINT_FIELD_D("{", caps, max_adj);
  92. PRINT_FIELD_D(", ", caps, n_alarm);
  93. PRINT_FIELD_D(", ", caps, n_ext_ts);
  94. PRINT_FIELD_D(", ", caps, n_per_out);
  95. PRINT_FIELD_D(", ", caps, pps);
  96. tprints("}");
  97. break;
  98. }
  99. default:
  100. return RVAL_DECODED;
  101. }
  102. return RVAL_IOCTL_DECODED;
  103. }
  104. #endif /* HAVE_STRUCT_PTP_SYS_OFFSET */