[strace/strace] Feature request: reads from inotify file descriptors should decode the struct (#199)

Masatake YAMATO notifications at github.com
Thu Oct 7 03:59:17 UTC 2021


Interesting.

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. 
But I wonder my study can help you implement what you want.

When decoding the buffer filled by read(2), you may want to know whether the fd
passed to read(2) is returned from inotify_init or not.
The hint is in the implementation of -y option.
If strace is run with -y option, the information of file descriptor is printed like:
```
read(3<inotify>, ...
```
At a quick glance, you can use the information `<inotfy>`. 
However, the current implementation is the information is just printed.
The information is not recorded for the successive decoding processes.

https://github.com/masatake/strace/commit/19bbc9dceee2e42a9745e099c2261060d7af1637
This change hooks printfd(), the core of -y option, for recording the information to struct tcb.

struct tcb has a field called `priv` to store such decoder-specific information.
However, if multiple decoders are involved in decoding one system call,  the decoders may conflicts.
So I introduced `priv` field multiplexer.
https://github.com/masatake/strace/commit/d564e4ccf3d0c5d16e965c35dd31992af1f1514d

Even if a user doesn't use -y option, you may want to decode the buffer.
So recording fd information and printing fd information should be able to be enabled independently.
For this purpose, I defined enable_tprint/disable_tprint.
https://github.com/masatake/strace/commit/bf6f39c2577240c940e1ff0839c92c68ea69faec
https://github.com/masatake/strace/commit/19bbc9dceee2e42a9745e099c2261060d7af1637

You can find all my changes in "Aug 27, 2021" in https://github.com/masatake/strace/commits/vfio-draft

I hope my study helps you.
NOTE: my changes are not approved by @ldv-alt yet. As I wrote, I didn't submit the changes to the mailing list.



-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/strace/strace/issues/199#issuecomment-937423441
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20211006/0d4e638a/attachment.htm>


More information about the Strace-devel mailing list