[PATCH 4/6] Fill fd_info structure only when a decoder requests
Masatake YAMATO
yamato at redhat.com
Thu Mar 10 12:01:04 UTC 2022
This is a minor optimization.
If a ioctl decoder wants to use fd_info as a hint, the
decoder call tell the request to its upper layer via
newly introduced function ioctl_does_expect_fd_info().
* src/ioctl.c (ioctl_does_expect_fd_info): New function.
(SYS_FUNC(ioctl)): Collect fd_info only when
ioctl_does_expect_fd_info() returns true.
Signed-off-by: Masatake YAMATO <yamato at redhat.com>
---
src/ioctl.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/ioctl.c b/src/ioctl.c
index 72e827d9c..75f2c30b7 100644
--- a/src/ioctl.c
+++ b/src/ioctl.c
@@ -429,6 +429,20 @@ ioctl_decode(struct tcb *tcp)
return 0;
}
+/*
+ * If your ioctl decoder needs the extra inforamtion
+ * about a fd for later processing, return true.
+ */
+static bool ioctl_does_expect_fd_info(struct tcb *tcp)
+{
+ const unsigned int code = tcp->u_arg[1];
+ switch (_IOC_TYPE(code)) {
+ case 'T':
+ return true;
+ }
+ return false;
+}
+
SYS_FUNC(ioctl)
{
const struct_ioctlent *iop;
@@ -437,7 +451,10 @@ SYS_FUNC(ioctl)
if (entering(tcp)) {
struct fd_info *fd_info = NULL;
- printfd_filling_info(tcp, tcp->u_arg[0], &fd_info);
+ printfd_filling_info(tcp, tcp->u_arg[0],
+ ioctl_does_expect_fd_info(tcp)
+ ? &fd_info
+ : NULL);
tprint_arg_next();
if (xlat_verbosity != XLAT_STYLE_ABBREV)
--
2.35.1
More information about the Strace-devel
mailing list