]> granicus.if.org Git - strace/commitdiff
aio: assorted iocb decoder updates
authorEugene Syromyatnikov <evgsyr@gmail.com>
Mon, 27 Aug 2018 20:17:17 +0000 (22:17 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 16 Jul 2019 11:41:18 +0000 (11:41 +0000)
* xlat/aio_iocb_flags.in: New file.
* defs.h (pollflags, rwf_flags): New declarations.
* configure.ac (AC_CHECK_MEMBERS): Check for aio_flags and aio_rw_flags
fields of struct iocb.
* aio.c [HAVE_STRUCT_IOCB_AIO_FLAGS]: Include "xlat/aio_iocb_flags.h".
(AIO_RW_FLAGS_FIELD): New macro definition, defined based on the
presence of HAVE_STRUCT_IOCB_AIO_RW_FLAGS macro.
(iocb_sub): Add SUB_POLL.
(tprint_lio_opcode): Change IOCB_CMD_POLL subtype to SUB_POLL.
(print_common_flags): Conditionalize on HAVE_STRUCT_IOCB_AIO_FLAGS
instead of IOCB_FLAG_RESFD.  Print aio_flags using aio_iocb_flags xlat.
(print_iocb_header): Always print aio_data.  Print aio_rw_flags if it
is non-zero.  Print aio_reqprio based on the presence of
IOCB_FLAG_IOPRIO flag in aio_flags (use print_ioprio if it set and print
as a signed integer otherwise).
(print_iocb): Decode SUB_POLL subtype.
* tests/aio.c: Update expected output.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
aio.c
configure.ac
defs.h
tests/aio.c
xlat/aio_iocb_flags.in [new file with mode: 0644]

diff --git a/aio.c b/aio.c
index a825cae34f92a3042020e6789e7b3e7565d560a5..190ab35ec08b3844e714ae6786d3e5623e605720 100644 (file)
--- a/aio.c
+++ b/aio.c
 
 #include "xlat/aio_cmds.h"
 
+#ifdef HAVE_STRUCT_IOCB_AIO_FLAGS
+# include "xlat/aio_iocb_flags.h"
+#endif
+
+#ifdef HAVE_STRUCT_IOCB_AIO_RW_FLAGS
+# define AIO_RW_FLAGS_FIELD aio_rw_flags
+#else
+# define AIO_RW_FLAGS_FIELD aio_reserved1
+#endif
+
 SYS_FUNC(io_setup)
 {
        if (entering(tcp))
@@ -32,7 +42,7 @@ SYS_FUNC(io_destroy)
 }
 
 enum iocb_sub {
-       SUB_NONE, SUB_COMMON, SUB_VECTOR
+       SUB_NONE, SUB_COMMON, SUB_VECTOR, SUB_POLL
 };
 
 static enum iocb_sub
@@ -44,7 +54,7 @@ tprint_lio_opcode(unsigned int cmd)
                [IOCB_CMD_FSYNC]        = SUB_NONE,
                [IOCB_CMD_FDSYNC]       = SUB_NONE,
                [IOCB_CMD_PREADX]       = SUB_NONE,
-               [IOCB_CMD_POLL]         = SUB_NONE,
+               [IOCB_CMD_POLL]         = SUB_POLL,
                [IOCB_CMD_NOOP]         = SUB_NONE,
                [IOCB_CMD_PREADV]       = SUB_VECTOR,
                [IOCB_CMD_PWRITEV]      = SUB_VECTOR,
@@ -59,13 +69,16 @@ tprint_lio_opcode(unsigned int cmd)
 static void
 print_common_flags(struct tcb *tcp, const struct iocb *cb)
 {
-/* IOCB_FLAG_RESFD is available since v2.6.22-rc1~47 */
-#ifdef IOCB_FLAG_RESFD
+/* aio_flags and aio_resfd fields are available since v2.6.22-rc1~47 */
+#ifdef HAVE_STRUCT_IOCB_AIO_FLAGS
+       if (cb->aio_flags)
+               PRINT_FIELD_FLAGS(", ", *cb, aio_flags, aio_iocb_flags,
+                                 "IOCB_FLAG_???");
+
        if (cb->aio_flags & IOCB_FLAG_RESFD)
                PRINT_FIELD_FD(", ", *cb, aio_resfd, tcp);
-
-       if (cb->aio_flags & ~IOCB_FLAG_RESFD)
-               PRINT_FIELD_X(", ", *cb, aio_flags);
+       else if (cb->aio_resfd)
+               PRINT_FIELD_X(", ", *cb, aio_resfd);
 #endif
 }
 
@@ -82,20 +95,25 @@ print_iocb_header(struct tcb *tcp, const struct iocb *cb)
 {
        enum iocb_sub sub;
 
-       if (cb->aio_data){
-               PRINT_FIELD_X("", *cb, aio_data);
-               tprints(", ");
-       }
+       PRINT_FIELD_X("", *cb, aio_data);
 
-       if (cb->aio_key) {
-               PRINT_FIELD_U("", *cb, aio_key);
-               tprints(", ");
+       if (cb->aio_key)
+               PRINT_FIELD_U(", ", *cb, aio_key);
+
+       if (cb->AIO_RW_FLAGS_FIELD) {
+               tprints(", aio_rw_flags=");
+               printflags(rwf_flags, cb->AIO_RW_FLAGS_FIELD, "RWF_???");
        }
 
-       tprints("aio_lio_opcode=");
+       tprints("aio_lio_opcode=");
        sub = tprint_lio_opcode(cb->aio_lio_opcode);
-       if (cb->aio_reqprio)
+
+       if (cb->aio_flags & IOCB_FLAG_IOPRIO) {
+               tprints(", aio_reqprio=");
+               print_ioprio(zero_extend_signed_to_ull(cb->aio_reqprio));
+       } else if (cb->aio_reqprio) {
                PRINT_FIELD_D(", ", *cb, aio_reqprio);
+       }
 
        PRINT_FIELD_FD(", ", *cb, aio_fildes, tcp);
 
@@ -135,6 +153,10 @@ print_iocb(struct tcb *tcp, const struct iocb *cb)
                PRINT_FIELD_D(", ", *cb, aio_offset);
                print_common_flags(tcp, cb);
                break;
+       case SUB_POLL:
+               PRINT_FIELD_FLAGS(", ", *cb, aio_buf, pollflags, "POLL???");
+               print_common_flags(tcp, cb);
+               break;
        case SUB_NONE:
                break;
        }
index 5441295ff73ffa44a45494b689bdc76ff9d3f35d..624fc7c0c35ab24e0c991c7f3a3654b466791c7b 100644 (file)
@@ -590,6 +590,11 @@ fi
 
 AC_CHECK_TYPES([struct __aio_sigset],,, [#include <linux/aio_abi.h>])
 
+AC_CHECK_MEMBERS(m4_normalize([
+               struct iocb.aio_flags,
+               struct iocb.aio_rw_flags
+               ]),,, [#include <linux/aio_abi.h>])
+
 CPPFLAGS="$saved_CPPFLAGS"
 
 AC_CHECK_HEADERS([linux/btrfs.h], [
diff --git a/defs.h b/defs.h
index 2b1d7a0074046f9ce72ded4bd206f19f2a03f81c..f71be3a25537787c71937424ce51919d2fa17c77 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -345,11 +345,13 @@ extern const struct xlat nl_netfilter_msg_types[];
 extern const struct xlat nl_route_types[];
 extern const struct xlat open_access_modes[];
 extern const struct xlat open_mode_flags[];
+extern const struct xlat pollflags[];
 extern const struct xlat ptrace_cmds[];
 extern const struct xlat resource_flags[];
 extern const struct xlat routing_scopes[];
 extern const struct xlat routing_table_ids[];
 extern const struct xlat routing_types[];
+extern const struct xlat rwf_flags[];
 extern const struct xlat seccomp_filter_flags[];
 extern const struct xlat seccomp_ret_action[];
 extern const struct xlat setns_types[];
index 1382199881941365e86068b0d8b18a99d1e38f2a..ff82c41e7b791be15f154d1e91b76467d01ac2cc 100644 (file)
@@ -117,7 +117,7 @@ main(void)
                        /* In order to make record valid */
                        .aio_nbytes = (size_t) 0x1020304050607080ULL,
                        .aio_offset = 0xdeadda7abadc0dedULL,
-# ifdef IOCB_FLAG_RESFD
+# ifdef HAVE_STRUCT_IOCB_AIO_FLAGS
                        .aio_flags = 0xfacef157,
                        .aio_resfd = 0xded1ca7e,
 # endif
@@ -298,30 +298,31 @@ main(void)
        printf("io_submit(%#lx, %ld, ["
               "{aio_data=%#" PRI__x64 ", aio_key=%u"
                ", aio_lio_opcode=%hu /* IOCB_CMD_??? */, aio_fildes=%d}"
-               ", {aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITE, aio_reqprio=%hd"
-               ", aio_fildes=%d, aio_buf=NULL"
+               ", {aio_data=0, aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITE"
+               ", aio_reqprio=IOPRIO_PRIO_VALUE(0x5 /* IOPRIO_CLASS_??? */"
+               ", 7919), aio_fildes=%d, aio_buf=NULL"
                ", aio_nbytes=%" PRI__u64 ", aio_offset=%" PRI__d64
-# ifdef IOCB_FLAG_RESFD
-               ", aio_resfd=%d, aio_flags=%#x"
+# ifdef HAVE_STRUCT_IOCB_AIO_FLAGS
+               ", aio_flags=IOCB_FLAG_RESFD|IOCB_FLAG_IOPRIO|%#x, aio_resfd=%d"
 # endif
-              "}, {aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITE"
+              "}, {aio_data=0, aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITE"
                ", aio_reqprio=%hd, aio_fildes=%d, aio_buf=%#" PRI__x64
                ", aio_nbytes=%" PRI__u64 ", aio_offset=%" PRI__d64
-              "}, {aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITE"
+              "}, {aio_data=0, aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITE"
                ", aio_reqprio=%hd, aio_fildes=%d"
                ", aio_buf=\"\\0\\1\\2\\3%.28s\"..."
                ", aio_nbytes=%" PRI__u64 ", aio_offset=%" PRI__d64
-              "}, {aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITEV"
+              "}, {aio_data=0, aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITEV"
                ", aio_reqprio=%hd, aio_fildes=%d, aio_buf=%#" PRI__x64
                ", aio_nbytes=%" PRI__u64 ", aio_offset=%" PRI__d64
               "}, NULL, %#lx, ... /* %p */]) = ",
               *ctx, 1057L,
               cbv2[0].aio_data, cbv2[0].aio_key,
               cbv2[0].aio_lio_opcode, cbv2[0].aio_fildes,
-              cbv2[1].aio_key, cbv2[1].aio_reqprio, cbv2[1].aio_fildes,
+              cbv2[1].aio_key, cbv2[1].aio_fildes,
               cbv2[1].aio_nbytes, cbv2[1].aio_offset,
-# ifdef IOCB_FLAG_RESFD
-              cbv2[1].aio_resfd, cbv2[1].aio_flags,
+# ifdef HAVE_STRUCT_IOCB_AIO_FLAGS
+              cbv2[1].aio_flags & ~3, cbv2[1].aio_resfd,
 # endif
               cbv2[2].aio_key, cbv2[2].aio_reqprio, cbv2[2].aio_fildes,
               cbv2[2].aio_buf, cbv2[2].aio_nbytes, cbv2[2].aio_offset,
diff --git a/xlat/aio_iocb_flags.in b/xlat/aio_iocb_flags.in
new file mode 100644 (file)
index 0000000..f6a5ab7
--- /dev/null
@@ -0,0 +1,2 @@
+IOCB_FLAG_RESFD                1
+IOCB_FLAG_IOPRIO       2