Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1286174
  • 博文数量: 168
  • 博客积分: 3483
  • 博客等级: 中校
  • 技术积分: 1696
  • 用 户 组: 普通用户
  • 注册时间: 2006-02-06 13:17
文章分类

全部博文(168)

文章存档

2015年(6)

2014年(9)

2013年(47)

2012年(11)

2011年(13)

2010年(18)

2009年(11)

2008年(42)

2007年(11)

分类: LINUX

2013-06-17 16:52:17

mount(2)
  1. SYSCALL_DEFINE.(mount, ...)
  2.   do_mount()
  3.     do_new_mount()
  4.       type = get_fs_type(char * fstype)
  5.         vfs_kern_mount(type, ...)
  6.           mount_fs(type, ...)
  7.             type->mount(type, ...)
open(2)
  1. SYSCALL_DEFINE.(open, ...)
  2.   do_sys_open()
  3.     fd = get_unused_fd_flags()
  4.     file = do_filp_open()
  5.       path_openat()
  6.         file = get_empty_filp()
  7.         link_path_walk()
  8.           xxx_lookup() --> {inode = xxx_iget(_sb, )} --> {init i_op & i_fop}
  9.         do_last()
  10.           lookup_open() --> may_open() --> {if (path->mnt->mnt_flags & MNT_NODEV) return -EACCES}
  11.         V
  1. //xxx_lookup->new_inode|xxx_iget()->new_inode_pseudo()->alloc_inode()
  2. //'.->i_fop =' {inode->i_fop = de->proc_fops;},{inode->i_fop = &xxx_file_ops;}
  3. //finish_open()->do_dentry_open()->{f->f_op = fops_get(inode->i_fop);}
  4. //open = f->f_op->open; error = open(inode, f); //some filesystem there is open() defined them self

generic_file_open
ext4_file_open
xfs_file_open
nfs_file_open


//对于特殊文件(chr,blk,fifo,sock) 每个文件系统初始化inode时,都会调用init_special_inode

const struct file_operations def_chr_fops = {  
    .open = chrdev_open,  
};
def_blk_fops
def_fifo_fops
bad_sock_fops
fs/xxx/inode.c: xxx_iget() --> init_special_inode()

fs/nfs/inode.c: nfs_fhget() --> init_special_inode()
对special文件,nfs处理有问题 //nfs 里面也是同样处理:注册的是本机特殊设备的fops;
如果用户不知道,导出/dev远程访问的话,其实访问的还是本机的设备文件;
    nfs应该注册自定义的fops,


read(2)
  1. SYSCALL_DEFINE.(read, ...)
  2.   vfs_read()
  3.     file->f_op->read()
  4.       //ext4 ...
  5.       ext4_file_operations.read = do_sync_read  //struct file_operations
  6.         ext4_file_operations.aio_read = generic_file_aio_read
  7.           do_generic_file_read()
  8.             mapping->a_ops->readpage()
  9.               ext4_ordered_aops.readpage = ext4_readpage  //struct address_space_operations
  10.                 ext4_get_block()
  1.       //proc default ...
  2.       //entry = create_proc_entry( fops=NULL ); entry->read_proc = xxxx_read_proc
  3.       proc_file_operations.read = proc_file_read
  4.         __proc_file_read()
  5.            dp->read_proc()  //if NULL -EIO

  6.       //proc special 1 ...
  7.       //proc_create( fops=arp_seq_fops )
  8.       arp_seq_fops.read
  9.         seq_read()

  10.       //proc special 2 ... http://blog.chinaunix.net/uid-20564848-id-73759.html
  11.       proc_sys_file_operations.read = proc_sys_read
  12.         table = do_proc_sys_lookup(dentry->d_parent, &dentry->d_name, &head);
  13.           table->proc_handler()  //.proc_handler = xxxx()

  14.       //proc special 3 ...
  15.       cache_file_operations_procfs.read
  16.         cache_read_procfs()
  17.           cache_read()
  18.             /*find next request*/
  19.             copy_to_user()



阅读(1347) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~