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.

rtc.c 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Copyright (c) 2004 Ulrich Drepper <drepper@redhat.com>
  3. * Copyright (c) 2004-2016 Dmitry V. Levin <ldv@altlinux.org>
  4. * Copyright (c) 2015-2018 The strace developers.
  5. * All rights reserved.
  6. *
  7. * SPDX-License-Identifier: LGPL-2.1-or-later
  8. */
  9. #include "defs.h"
  10. #include DEF_MPERS_TYPE(struct_rtc_pll_info)
  11. #include <linux/ioctl.h>
  12. #include <linux/rtc.h>
  13. typedef struct rtc_pll_info struct_rtc_pll_info;
  14. #include MPERS_DEFS
  15. static void
  16. print_rtc_time(struct tcb *tcp, const struct rtc_time *rt)
  17. {
  18. tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, "
  19. "tm_mday=%d, tm_mon=%d, tm_year=%d, ",
  20. rt->tm_sec, rt->tm_min, rt->tm_hour,
  21. rt->tm_mday, rt->tm_mon, rt->tm_year);
  22. if (!abbrev(tcp))
  23. tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}",
  24. rt->tm_wday, rt->tm_yday, rt->tm_isdst);
  25. else
  26. tprints("...}");
  27. }
  28. static void
  29. decode_rtc_time(struct tcb *const tcp, const kernel_ulong_t addr)
  30. {
  31. struct rtc_time rt;
  32. if (!umove_or_printaddr(tcp, addr, &rt))
  33. print_rtc_time(tcp, &rt);
  34. }
  35. static void
  36. decode_rtc_wkalrm(struct tcb *const tcp, const kernel_ulong_t addr)
  37. {
  38. struct rtc_wkalrm wk;
  39. if (!umove_or_printaddr(tcp, addr, &wk)) {
  40. tprintf("{enabled=%d, pending=%d, time=", wk.enabled, wk.pending);
  41. print_rtc_time(tcp, &wk.time);
  42. tprints("}");
  43. }
  44. }
  45. static void
  46. decode_rtc_pll_info(struct tcb *const tcp, const kernel_ulong_t addr)
  47. {
  48. struct_rtc_pll_info pll;
  49. if (!umove_or_printaddr(tcp, addr, &pll))
  50. tprintf("{pll_ctrl=%d, pll_value=%d, pll_max=%d, pll_min=%d"
  51. ", pll_posmult=%d, pll_negmult=%d, pll_clock=%ld}",
  52. pll.pll_ctrl, pll.pll_value, pll.pll_max, pll.pll_min,
  53. pll.pll_posmult, pll.pll_negmult, (long) pll.pll_clock);
  54. }
  55. MPERS_PRINTER_DECL(int, rtc_ioctl, struct tcb *const tcp,
  56. const unsigned int code, const kernel_ulong_t arg)
  57. {
  58. switch (code) {
  59. case RTC_ALM_READ:
  60. case RTC_RD_TIME:
  61. if (entering(tcp))
  62. return 0;
  63. ATTRIBUTE_FALLTHROUGH;
  64. case RTC_ALM_SET:
  65. case RTC_SET_TIME:
  66. tprints(", ");
  67. decode_rtc_time(tcp, arg);
  68. break;
  69. case RTC_IRQP_SET:
  70. case RTC_EPOCH_SET:
  71. tprintf(", %" PRI_klu, arg);
  72. break;
  73. case RTC_IRQP_READ:
  74. case RTC_EPOCH_READ:
  75. if (entering(tcp))
  76. return 0;
  77. tprints(", ");
  78. printnum_ulong(tcp, arg);
  79. break;
  80. case RTC_WKALM_RD:
  81. if (entering(tcp))
  82. return 0;
  83. ATTRIBUTE_FALLTHROUGH;
  84. case RTC_WKALM_SET:
  85. tprints(", ");
  86. decode_rtc_wkalrm(tcp, arg);
  87. break;
  88. case RTC_PLL_GET:
  89. if (entering(tcp))
  90. return 0;
  91. ATTRIBUTE_FALLTHROUGH;
  92. case RTC_PLL_SET:
  93. tprints(", ");
  94. decode_rtc_pll_info(tcp, arg);
  95. break;
  96. #ifdef RTC_VL_READ
  97. case RTC_VL_READ:
  98. if (entering(tcp))
  99. return 0;
  100. tprints(", ");
  101. printnum_int(tcp, arg, "%d");
  102. break;
  103. #endif
  104. case RTC_AIE_ON:
  105. case RTC_AIE_OFF:
  106. case RTC_UIE_ON:
  107. case RTC_UIE_OFF:
  108. case RTC_PIE_ON:
  109. case RTC_PIE_OFF:
  110. case RTC_WIE_ON:
  111. case RTC_WIE_OFF:
  112. #ifdef RTC_VL_CLR
  113. case RTC_VL_CLR:
  114. #endif
  115. /* no args */
  116. break;
  117. default:
  118. return RVAL_DECODED;
  119. }
  120. return RVAL_IOCTL_DECODED;
  121. }