Linux 通过ftrace跟踪当前系统操作的文件和进程

    1、cd sys/kernel/debug/tracing/events/android_fs
    2、echo 1 > enable
    android_fs_dataread_start
    android_fs_dataread_end
    android_fs_datawrite_start
    android_fs_datawrite_end
    android_fs_fsync_start
    android_fs_fsync_end
   3、 echo 'android_fs_dataread_start android_fs_dataread_end android_fs_datawrite_start android_fs_datawrite_end' > set_event
    4、cat trace

如下可以看到哪些pid在操作哪些inode:

log如下:  

 test-4677  [003] ....  7017.061333: android_fs_datawrite_end: ino 16, offset 4119400, bytes 94
    testbin-4677  [003] ....  7017.061394: android_fs_datawrite_start: entry_name /testbin.cap0, offset 4119494, bytes 94, cmdline testbin, pid 4677, i_size 4119494, ino 16
    testbin-4677  [003] ....  7017.061431: android_fs_datawrite_end: ino 16, offset 4119494, bytes 94
    testbin-4677  [003] ....  7017.061496: android_fs_datawrite_start: entry_name /testbin.cap0, offset 4119588, bytes 114, cmdline testbin, pid 4677, i_size 4119588, ino 16
    testbin-4677  [003] ....  7017.061526: android_fs_datawrite_end: ino 16, offset 4119588, bytes 114
    testbin-4677  [003] ....  7017.061588: android_fs_datawrite_start: entry_name /testbin.cap0, offset 4119702, bytes 114, cmdline testbin, pid 4677, i_size 4119702, ino 16
    testbin-4677  [003] ....  7017.061617: android_fs_datawrite_end: ino 16, offset 4119702, bytes 114

  • 5
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

a2591748032-随心所记

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值