summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Syromyatnikov <evgsyr@gmail.com>2022-06-12 19:32:22 +0200
committerDmitry V. Levin <ldv@strace.io>2022-06-12 17:32:22 +0000
commitaeb29a3238ef3cc7f191f98743678d3b4ec949b9 (patch)
tree16c984b7cd9d001e34b78de1a76fecd6dc06f99c
parent505de19f84c68f378fcc48dd6c42a6a1240de477 (diff)
downloadstrace-aeb29a3238ef3cc7f191f98743678d3b4ec949b9.tar.gz
io_uring: work aroung struct io_uring_rsrc_register field name change
resv field has been renamed to flags in Linux commit v5.19-rc1~251^2~20, provide a shim to support old decoding syntax. * configure.ac (AC_CHECK_TYPES): Add struct io_uring_rsrc_register and struct io_uring_rsrc_register.resv checks. * src/io_uring.c [HAVE_STRUCT_IO_URING_RSRC_REGISTER_RESV] (RESV): Define as resv. [!HAVE_STRUCT_IO_URING_RSRC_REGISTER_RESV] (RESV): Define as flags. (print_io_uring_register_rsrc): Use RESV instead of resv; print "resv" field name explicitly and use PRINT_VAL_X instead of PRINT_FIELD_X. * tests/io_uring_register.c [HAVE_STRUCT_IO_URING_RSRC_REGISTER_RESV] (RESV): Define as resv. [!HAVE_STRUCT_IO_URING_RSRC_REGISTER_RESV] (RESV): Define as flags. (main): Use RESV to access struct io_uring_rsrc_register.resv field.
-rw-r--r--configure.ac6
-rw-r--r--src/io_uring.c16
-rw-r--r--tests/io_uring_register.c9
3 files changed, 27 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac
index 27faa1a81..ef9810dd0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -571,6 +571,12 @@ AC_CHECK_MEMBERS(m4_normalize([
struct iocb.aio_rw_flags
]),,, [#include <linux/aio_abi.h>])
+AC_CHECK_TYPES([struct io_uring_rsrc_register], [
+ AC_CHECK_MEMBERS(m4_normalize([
+ struct io_uring_rsrc_register.resv
+ ]),,, [#include <linux/io_uring.h>])
+],, [#include <linux/io_uring.h>])
+
CPPFLAGS="$saved_CPPFLAGS"
st_CHECK_ENUMS
diff --git a/src/io_uring.c b/src/io_uring.c
index be86ca41e..706c481c3 100644
--- a/src/io_uring.c
+++ b/src/io_uring.c
@@ -385,13 +385,20 @@ print_io_uring_rsrc_tags(struct tcb *tcp, const uint64_t tags,
tfetch_mem, print_xint_array_member, NULL);
}
+/* Work around field name change in Linux commit v5.19-rc1~251^2~20. */
+#ifdef HAVE_STRUCT_IO_URING_RSRC_REGISTER_RESV
+# define RESV resv
+#else
+# define RESV flags
+#endif
+
static void
print_io_uring_register_rsrc(struct tcb *tcp, const kernel_ulong_t addr,
const unsigned int size, const unsigned int opcode)
{
struct io_uring_rsrc_register arg;
CHECK_TYPE_SIZE(arg, 32);
- CHECK_TYPE_SIZE(arg.resv, sizeof(uint32_t));
+ CHECK_TYPE_SIZE(arg.RESV, sizeof(uint32_t));
CHECK_TYPE_SIZE(arg.resv2, sizeof(uint64_t));
if (size < 32) {
@@ -405,9 +412,10 @@ print_io_uring_register_rsrc(struct tcb *tcp, const kernel_ulong_t addr,
tprint_struct_begin();
PRINT_FIELD_U(arg, nr);
- if (arg.resv) {
+ if (arg.RESV) {
tprint_struct_next();
- PRINT_FIELD_X(arg, resv);
+ tprints_field_name("resv");
+ PRINT_VAL_X(arg.RESV);
}
if (arg.resv2) {
@@ -427,6 +435,8 @@ print_io_uring_register_rsrc(struct tcb *tcp, const kernel_ulong_t addr,
tprint_struct_end();
}
+#undef RESV
+
static void
print_io_uring_update_rsrc(struct tcb *tcp, const kernel_ulong_t addr,
const unsigned int size, const unsigned int opcode)
diff --git a/tests/io_uring_register.c b/tests/io_uring_register.c
index 17bc97466..5f37689fe 100644
--- a/tests/io_uring_register.c
+++ b/tests/io_uring_register.c
@@ -44,6 +44,13 @@
#define ARR_ITEM(arr_, idx_) ((arr_)[(idx_) % ARRAY_SIZE(arr_)])
+/* Work around field name change in Linux commit v5.19-rc1~251^2~20. */
+#ifdef HAVE_STRUCT_IO_URING_RSRC_REGISTER_RESV
+# define RESV resv
+#else
+# define RESV flags
+#endif
+
static const char path_null[] = "/dev/null";
static const char path_full[] = "/dev/full";
@@ -702,7 +709,7 @@ main(void)
rsrc_reg->nr += !!(j & 16);
rsrc_reg->nr &= ~-!(j & 32);
- rsrc_reg->resv = j & 64 ? 0xbadc0ded : 0;
+ rsrc_reg->RESV = j & 64 ? 0xbadc0ded : 0;
rsrc_reg->resv2 = j & 128 ? 0xfacecafebeeffeedULL : 0;
memcpy(big_rsrc_reg, rsrc_reg, sizeof(*rsrc_reg));