1 Star2 Stars3 Stars4 Stars5 Stars (还没有评分)
Loading...

DTraceToolkit脚本解析(8)-creatbyproc.d

creatbyproc.d位于DTraceToolkitProc文件夹下,其功能是打印调用creat系统调用的进程名和创建的文件名。脚本代码就一行(略去版权信息):

syscall::creat*:entry { printf("%s %s", execname, copyinstr(arg0)); }

脚本代码分析如下:
监听creat(或者creat64)系统调用的 entry probe,其中arg0参数记录了要创建的文件名。当probe触发后,打印进程名和创建的文件名。

执行脚本,输出如下:

bash-3.2# ./creatbyproc.d
dtrace: script './creatbyproc.d' matched 2 probes
CPU     ID                    FUNCTION:NAME
  0  57233                    creat64:entry sh /tmp/mpsYaiuL
  4  57233                    creat64:entry sh /dev/null
  0  57233                    creat64:entry sh /dev/null
  5  57233                    creat64:entry sh /dev/null

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.