<p></p>
<p>Interesting.</p>
<p>I studied how to store information in /proc/$pid/fdinfo/$fd to the private fields of tcb for decoding ioctl about vfio. My code requires a change to the Linux kernel. So I didn't submit the result of the study to the strace mailing list.<br>
But I wonder my study can help you implement what you want.</p>
<p>When decoding the buffer filled by read(2), you may want to know whether the fd<br>
passed to read(2) is returned from inotify_init or not.<br>
The hint is in the implementation of -y option.<br>
If strace is run with -y option, the information of file descriptor is printed like:</p>
<pre><code>read(3<inotify>, ...
</code></pre>
<p>At a quick glance, you can use the information <code><inotfy></code>.<br>
However, the current implementation is the information is just printed.<br>
The information is not recorded for the successive decoding processes.</p>
<p><a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/masatake/strace/commit/19bbc9dceee2e42a9745e099c2261060d7af1637/hovercard" href="https://github.com/masatake/strace/commit/19bbc9dceee2e42a9745e099c2261060d7af1637">masatake@<tt>19bbc9d</tt></a><br>
This change hooks printfd(), the core of -y option, for recording the information to struct tcb.</p>
<p>struct tcb has a field called <code>priv</code> to store such decoder-specific information.<br>
However, if multiple decoders are involved in decoding one system call,  the decoders may conflicts.<br>
So I introduced <code>priv</code> field multiplexer.<br>
<a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/masatake/strace/commit/d564e4ccf3d0c5d16e965c35dd31992af1f1514d/hovercard" href="https://github.com/masatake/strace/commit/d564e4ccf3d0c5d16e965c35dd31992af1f1514d">masatake@<tt>d564e4c</tt></a></p>
<p>Even if a user doesn't use -y option, you may want to decode the buffer.<br>
So recording fd information and printing fd information should be able to be enabled independently.<br>
For this purpose, I defined enable_tprint/disable_tprint.<br>
<a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/masatake/strace/commit/bf6f39c2577240c940e1ff0839c92c68ea69faec/hovercard" href="https://github.com/masatake/strace/commit/bf6f39c2577240c940e1ff0839c92c68ea69faec">masatake@<tt>bf6f39c</tt></a><br>
<a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/masatake/strace/commit/19bbc9dceee2e42a9745e099c2261060d7af1637/hovercard" href="https://github.com/masatake/strace/commit/19bbc9dceee2e42a9745e099c2261060d7af1637">masatake@<tt>19bbc9d</tt></a></p>
<p>You can find all my changes in "Aug 27, 2021" in <a href="https://github.com/masatake/strace/commits/vfio-draft">https://github.com/masatake/strace/commits/vfio-draft</a></p>
<p>I hope my study helps you.<br>
NOTE: my changes are not approved by <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/users/ldv-alt/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ldv-alt">@ldv-alt</a> yet. As I wrote, I didn't submit the changes to the mailing list.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/strace/strace/issues/199#issuecomment-937423441">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AOVBTR45XC53NEWZLXIIU33UFULJLANCNFSM5FQBRZUQ">unsubscribe</a>.<br />Triage notifications on the go with GitHub Mobile for <a href="https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub">Android</a>.
<img src="https://github.com/notifications/beacon/AOVBTR4DP67QVOBKDAZ2DHTUFULJLA5CNFSM5FQBRZU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOG7P7EUI.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/strace/strace/issues/199#issuecomment-937423441",
"url": "https://github.com/strace/strace/issues/199#issuecomment-937423441",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>