vfs_path_lookup

   1: void lookupInode()
   2: {
   3:     struct dentry* root_dentry;
   4:     struct vfsmount* root_mnt;
   5:     const char* filename;
   6:     struct nameidata data;
   7:     int err = 0;
   8:  
   9:     root_dentry = current->fs->root.dentry;
  10:     root_mnt = current->fs->root.mnt;
  11:     filename = "/mod/case/superblock/tmp";
  12:     //filename = "/boot/vmlinuz-3.0.0-12-generic";
  13:     //filename = "/";
  14:     filename = "/home/danie/filelist.c";
  15:     //filename = "/home/daniel";
  16:     //filename = "/mod/case/superblock/tmp";
  17:     err = vfs_path_lookup(root_dentry,root_mnt,filename,LOOKUP_EXCL,&data);
  18:     printk("lookup %s
", filename);
  19:     if (err==0)
  20:     {
  21:         struct inode* nodei = data.inode;
  22:         struct address_space* mapping = nodei->i_mapping;
  23:         printk("mapping 0x%08x
", mapping);
  24:         printk("nr_pages: %d
", mapping->nrpages);
  25:         
  26:         //printk("Showing:
");
  27:         printRawData(sizeof(struct inode),nodei);
  28:         
  29:     }
  30:     else
  31:         printk("err: %d
", err);
  32:  
  33: }

vfs_path_lookup为什么读不到文件,但是能够读到目录?

原文地址:https://www.cnblogs.com/long123king/p/3535664.html