crash files command

显示的内容是当前上下文打开文件的信息


如果研究文件系统,可以参考该命令
crash> help files
NAME
  files - open files

SYNOPSIS
  files [-d dentry] | [-R reference] [pid | taskp] ...

DESCRIPTION
/*显示的内容是当前上下文打开文件的信息
 *信息包括
 *1]root dirctory and current working directory;
 *2]pointer to file discriptor, dentry struct, inode, file type and the pathname
 **/

  This command displays information about open files of a context.
  It prints the context's current root directory and current working
  directory, and then for each open file descriptor it prints a pointer
  to its file struct, a pointer to its dentry struct, a pointer to the
  inode, the file type, and the pathname.  
/*files 后没有参数,使用的就是当前上下文,也就是所说的当前进程;
 *进程的pid and taskp 可以指定进程
 **/

  If no arguments are entered,the current context is used.  
  The -R option, typically invoked from
  "foreach files", searches for references to a supplied number, address,
  or filename argument, and prints only the essential information leading
  up to and including the reference.  
 
  The -d option is not context
  specific, and only shows the data requested.

     -d dentry  given a hexadecimal dentry address, display its inode,
                super block, file type, and full pathname.
  -R reference  search for references to this file descriptor number,
                filename, or dentry, inode, or file structure address.
           pid  a process PID.
         taskp  a hexadecimal task_struct pointer.

EXAMPLES
  Display the open files of the current context:

    crash> files
    PID: 1320   TASK: e6915be0  CPU: 0   COMMAND: "sh"
    ROOT: /    CWD: /
     FD    FILE     DENTRY    INODE    TYPE  PATH
      0  e61ab6e0  e64485d8  e61b37a8  CHR   /dev/console
      1  d8651180  e675bbd8  e6758068  REG   /proc/sysrq-trigger
      2  e61ab6e0  e64485d8  e61b37a8  CHR   /dev/console
      8  e6b101e0  e64094d8  e684a1c8  REG   /dev/__properties__
     24  e63dc700  e6445eb8  e61ae8e8  CHR   /dev/tty
     25  e61ab6e0  e64485d8  e61b37a8  CHR   /dev/console

    
      Display the files opened by the "crond" daemon, which is PID 462:

    crash> files 1320
    PID: 1320   TASK: e6915be0  CPU: 0   COMMAND: "sh"
    ROOT: /    CWD: /
     FD    FILE     DENTRY    INODE    TYPE  PATH
      0  e61ab6e0  e64485d8  e61b37a8  CHR   /dev/console
      1  d8651180  e675bbd8  e6758068  REG   /proc/sysrq-trigger
      2  e61ab6e0  e64485d8  e61b37a8  CHR   /dev/console
      8  e6b101e0  e64094d8  e684a1c8  REG   /dev/__properties__
     24  e63dc700  e6445eb8  e61ae8e8  CHR   /dev/tty
     25  e61ab6e0  e64485d8  e61b37a8  CHR   /dev/console
 
  The -R option is typically invoked from "foreach files".  This example
  shows all tasks that have "/dev/pts/4" open:

    crash> foreach files -R pts/4
    PID: 18633  TASK: c310a000  CPU: 0   COMMAND: "crash"
    ROOT: /    CWD: /home/CVS_pool/crash
     FD    FILE     DENTRY    INODE    TYPE  PATH
      0  c1412850  c2cb96d0  c2cad430  CHR   /dev/pts/4
      1  c1412850  c2cb96d0  c2cad430  CHR   /dev/pts/4
      2  c1412850  c2cb96d0  c2cad430  CHR   /dev/pts/4
    
    ----
    
    PID: 23159  TASK: c10fc000  CPU: 1   COMMAND: "xterm"
    ROOT: /    CWD: /homes/anderson/
     FD    FILE     DENTRY    INODE    TYPE  PATH
      5  c1560da0  c2cb96d0  c2cad430  CHR   /dev/pts/4
 
  Display information about the dentry at address e64485d8:

    crash> files -d e64485d8
     DENTRY    INODE    SUPERBLK  TYPE  PATH
    e64485d8  e61b37a8  e630cc00  CHR   /dev/console

使用实例:

ssize_t alb_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos)
{
    struct alb_driver_context *albdev = filp->private_data;
    struct albimage_dev *albimage = albdev->albimage;

   -----

}

想知道struct alb_driver_context *albdev,需要首先知道 file,  怎样知道file?

从task_struct的成员变量:


crash> struct task_struct.files ed415400
  files = 0xee17c280
crash> struct files_struct.file 0xee17c280
struct: invalid data structure reference: files_struct.file
crash> struct files_struct.fd_array 0xee17c280
  fd_array = {0xee0f82a0, 0xee0f82a0, 0xee0f82a0, 0xed402940, 0xed4d7c80, 0xed4d7a00, 0xed4d7820, 0xee13d200, 0xee13d660, 0xed4060c0, 0xed407f40, 0xed4debc0, 0xee0e5460, 0xed402c60, 0xedb8bf20, 0xee0e55a0, 0xee0e51e0, 0xee0e53c0, 0xedb9e8e0, 0xedbffaa0, 0xe137d5a0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}


crash> struct file.f_path 0xe137d5a0
  f_path = {
    mnt = 0xee01def0,
    dentry = 0xedd8a448
  }
crash> struct dentry.d_iname 0xedd8a448
  d_iname = "albimg\000\377\377\377\377\377\377\373\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\357\377\377"
crash> struct file 0xe137d5a0
struct file {
  private_data = 0xee203cc0,
--

}


crash> struct alb_driver_context 0xee203cc0
struct alb_driver_context {
  albimage = 0xed9142e0,
  write_from = 0xf3000000 struct: seek error: kernel virtual address: f3000000  type: "gdb_readmem_callback"
struct: seek error: kernel virtual address: f3000000  type: "gdb_readmem_callback"
<Address 0xf3000000 out of bounds>,
  read_from = 0xf5000000 struct: seek error: physical address: 0  type: "page table"
}


crash> struct albimage_dev 0xed9142e0
struct albimage_dev {
  ap_reset_bp_base = 0xfc821004,
  bp_image_load_base = 0xf3000000,
  bp_image_load_base_phy = 0x80000000,
  bp_image_size = 0x0,
  dev = 0xc0728d00 <tl7689_alb_device+8>,
  alb_context = 0xee203cc0
}

使用files command

crash> files
PID: 1487   TASK: ed415400  CPU: 0   COMMAND: "rild-tl"
ROOT: /    CWD: /
 FD    FILE     DENTRY    INODE    TYPE  PATH
  0  ee0f82a0  edc1f888  edb31830  CHR   /dev/null
  1  ee0f82a0  edc1f888  edb31830  CHR   /dev/null
  2  ee0f82a0  edc1f888  edb31830  CHR   /dev/null
  3  ed402940  ede20b30  eddae980  SOCK  
  4  ed4d7c80  edd7a6f0  ed4ede10  CHR   /dev/log/main
  5  ed4d7a00  edd74c40  ed4e39f0  CHR   /dev/log/radio
  6  ed4d7820  edd741a0  ed4e3270  CHR   /dev/log/events
  7  ee13d200  edd7ad50  ed4e8370  CHR   /dev/log/system
  8  ee13d660  edd1cee8  ee0887f0  REG   /dev/__properties__
  9  ed4060c0  edda3aa8  edc186c0  SOCK  
 10  ed407f40  edda3910  edc18540  SOCK  
 11  ed4debc0  ede634d0  ede6fba8  REG   /sys/devices/platform/tl7689_smd/k2u/modem_state/BPState
 12  ee0e5460  eded5dd8  ede6fa50  FIFO  
 13  ed402c60  eded5dd8  ede6fa50  FIFO  
 14  edb8bf20  edd64c40  ed40eb10  CHR   /dev/ttyN0
 15  ee0e55a0  eddf2228  eddf7490  REG   /sys/power/wake_lock
 16  ee0e51e0  eddf21a0  eddf7338  REG   /sys/power/wake_unlock
 17  ee0e53c0  edd77cc8  ed4e8df0  CHR   /dev/binder
 18  edb9e8e0  edf62910  ede29520  SOCK  
 19  edbffaa0  ede634d0  ede6fba8  REG   /sys/devices/platform/tl7689_smd/k2u/modem_state/BPState
 20  e137d5a0  edd8a448  ed546e50  CHR   /dev/albimg

还是files命令比较直接

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值