Skip to content

tools/opensnoop: support mount parent full-path#5324

Closed
Rtoax wants to merge 1 commit intoiovisor:masterfrom
Rtoax:patch-93-opensnoop-cwd-v0
Closed

tools/opensnoop: support mount parent full-path#5324
Rtoax wants to merge 1 commit intoiovisor:masterfrom
Rtoax:patch-93-opensnoop-cwd-v0

Conversation

@Rtoax
Copy link
Contributor

@Rtoax Rtoax commented May 30, 2025

Like d_path()/prepend_path() [1] did, get mount parent full-path.

For example, /dev/sda mount on /home/sda:

$ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda           8:0    0   1.8T  0 disk /home/sda

and open file under /home/sda/:

$ cd /home/sda/git-repos/tst-linux
$ touch a.out

Old tracing, only get the mount root:

$ sudo ./opensnoop.py -F
PID    COMM               FD ERR PATH
114293 touch               3   0 /git-repos/test-linux/a.out

This patch get real full path:

$ sudo ./opensnoop.py -F
PID    COMM               FD ERR PATH
114110 touch               3   0 /home/sda/git-repos/test-linux/a.out
                                 ^^^^^^^^^

Link: https://github.com/torvalds/linux/blob/master/fs/d_path.c [1]

Like d_path()/prepend_path() [1] did, get mount parent full-path.

For example, /dev/sda mount on /home/sda:

    $ lsblk
    NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
    sda           8:0    0   1.8T  0 disk /home/sda

and open file under /home/sda/:

    $ cd /home/sda/git-repos/tst-linux
    $ touch a.out

Old tracing, only get the mount root:

    $ sudo ./opensnoop.py -F
    PID    COMM               FD ERR PATH
    114293 touch               3   0 /git-repos/test-linux/a.out

This patch get real full path:

    $ sudo ./opensnoop.py -F
    PID    COMM               FD ERR PATH
    114110 touch               3   0 /home/sda/git-repos/test-linux/a.out
                                     ^^^^^^^^^

Link: https://github.com/torvalds/linux/blob/master/fs/d_path.c [1]
Signed-off-by: Rong Tao <rongtao@cestc.cn>
@Rtoax
Copy link
Contributor Author

Rtoax commented Jun 7, 2025

Perhaps we need to first address the issue of multiple processing of events caused by the full-path patch, which was introduced in c110a4d. Each loop iteration will send out an event, which is too much and unnecessary. cc @yonghong-song

@yonghong-song
Copy link
Collaborator

Sounds good. Let us resolve #5323 first and then deal with this patch.

@Rtoax
Copy link
Contributor Author

Rtoax commented Jun 13, 2025

Perhaps we need to first address the issue of multiple processing of events caused by the full-path patch, which was introduced in c110a4d. Each loop iteration will send out an event, which is too much and unnecessary. cc @yonghong-song

Close this PR and fix this first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants