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.

ubi.c 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * Copyright (c) 2012 Mike Frysinger <vapier@gentoo.org>
  3. * Copyright (c) 2012-2018 The strace developers.
  4. *
  5. * SPDX-License-Identifier: LGPL-2.1-or-later
  6. */
  7. #include "defs.h"
  8. #ifdef HAVE_STRUCT_UBI_ATTACH_REQ_MAX_BEB_PER1024
  9. # include <linux/ioctl.h>
  10. # include <mtd/ubi-user.h>
  11. # include "xlat/ubi_volume_types.h"
  12. # include "xlat/ubi_volume_props.h"
  13. int
  14. ubi_ioctl(struct tcb *const tcp, const unsigned int code,
  15. const kernel_ulong_t arg)
  16. {
  17. if (!verbose(tcp))
  18. return RVAL_DECODED;
  19. switch (code) {
  20. case UBI_IOCMKVOL:
  21. if (entering(tcp)) {
  22. struct ubi_mkvol_req mkvol;
  23. tprints(", ");
  24. if (umove_or_printaddr(tcp, arg, &mkvol))
  25. break;
  26. tprintf("{vol_id=%" PRIi32 ", alignment=%" PRIi32
  27. ", bytes=%" PRIi64 ", vol_type=", mkvol.vol_id,
  28. mkvol.alignment, (int64_t)mkvol.bytes);
  29. printxval(ubi_volume_types,
  30. (uint8_t) mkvol.vol_type, "UBI_???_VOLUME");
  31. tprintf(", name_len=%" PRIi16 ", name=",
  32. mkvol.name_len);
  33. print_quoted_cstring(mkvol.name,
  34. CLAMP(mkvol.name_len, 0,
  35. UBI_MAX_VOLUME_NAME));
  36. tprints("}");
  37. return 0;
  38. }
  39. if (!syserror(tcp)) {
  40. tprints(" => ");
  41. printnum_int(tcp, arg, "%d");
  42. }
  43. break;
  44. case UBI_IOCRSVOL: {
  45. struct ubi_rsvol_req rsvol;
  46. tprints(", ");
  47. if (umove_or_printaddr(tcp, arg, &rsvol))
  48. break;
  49. tprintf("{vol_id=%" PRIi32 ", bytes=%" PRIi64 "}",
  50. rsvol.vol_id, (int64_t)rsvol.bytes);
  51. break;
  52. }
  53. case UBI_IOCRNVOL: {
  54. struct ubi_rnvol_req rnvol;
  55. int c;
  56. tprints(", ");
  57. if (umove_or_printaddr(tcp, arg, &rnvol))
  58. break;
  59. tprintf("{count=%" PRIi32 ", ents=[", rnvol.count);
  60. for (c = 0; c < CLAMP(rnvol.count, 0, UBI_MAX_RNVOL); ++c) {
  61. if (c)
  62. tprints(", ");
  63. tprintf("{vol_id=%" PRIi32 ", name_len=%" PRIi16
  64. ", name=", rnvol.ents[c].vol_id,
  65. rnvol.ents[c].name_len);
  66. print_quoted_cstring(rnvol.ents[c].name,
  67. CLAMP(rnvol.ents[c].name_len, 0,
  68. UBI_MAX_VOLUME_NAME));
  69. tprints("}");
  70. }
  71. tprints("]}");
  72. break;
  73. }
  74. case UBI_IOCEBCH: {
  75. struct ubi_leb_change_req leb;
  76. tprints(", ");
  77. if (umove_or_printaddr(tcp, arg, &leb))
  78. break;
  79. tprintf("{lnum=%d, bytes=%d}", leb.lnum, leb.bytes);
  80. break;
  81. }
  82. case UBI_IOCATT:
  83. if (entering(tcp)) {
  84. struct ubi_attach_req attach;
  85. tprints(", ");
  86. if (umove_or_printaddr(tcp, arg, &attach))
  87. break;
  88. tprintf("{ubi_num=%" PRIi32 ", mtd_num=%" PRIi32
  89. ", vid_hdr_offset=%" PRIi32
  90. ", max_beb_per1024=%" PRIi16 "}",
  91. attach.ubi_num, attach.mtd_num,
  92. attach.vid_hdr_offset, attach.max_beb_per1024);
  93. return 0;
  94. }
  95. if (!syserror(tcp)) {
  96. tprints(" => ");
  97. printnum_int(tcp, arg, "%d");
  98. }
  99. break;
  100. case UBI_IOCEBMAP: {
  101. struct ubi_map_req map;
  102. tprints(", ");
  103. if (umove_or_printaddr(tcp, arg, &map))
  104. break;
  105. tprintf("{lnum=%" PRIi32 ", dtype=%" PRIi8 "}",
  106. map.lnum, map.dtype);
  107. break;
  108. }
  109. case UBI_IOCSETVOLPROP: {
  110. struct ubi_set_vol_prop_req prop;
  111. tprints(", ");
  112. if (umove_or_printaddr(tcp, arg, &prop))
  113. break;
  114. tprints("{property=");
  115. printxval(ubi_volume_props, prop.property, "UBI_VOL_PROP_???");
  116. tprintf(", value=%#" PRIx64 "}", (uint64_t)prop.value);
  117. break;
  118. }
  119. case UBI_IOCVOLUP:
  120. tprints(", ");
  121. printnum_int64(tcp, arg, "%" PRIi64);
  122. break;
  123. case UBI_IOCDET:
  124. case UBI_IOCEBER:
  125. case UBI_IOCEBISMAP:
  126. case UBI_IOCEBUNMAP:
  127. case UBI_IOCRMVOL:
  128. tprints(", ");
  129. printnum_int(tcp, arg, "%d");
  130. break;
  131. # ifdef UBI_IOCVOLCRBLK
  132. case UBI_IOCVOLCRBLK:
  133. # endif
  134. # ifdef UBI_IOCVOLRMBLK
  135. case UBI_IOCVOLRMBLK:
  136. # endif
  137. /* no arguments */
  138. break;
  139. default:
  140. return RVAL_DECODED;
  141. }
  142. return RVAL_IOCTL_DECODED;
  143. }
  144. #endif /* HAVE_STRUCT_UBI_ATTACH_REQ_MAX_BEB_PER1024 */