-
SYSCALL_DEFINE.(open, ...)
-
do_sys_open()
-
fd = get_unused_fd_flags()
-
file = do_filp_open()
-
path_openat()
-
file = get_empty_filp()
-
link_path_walk()
-
xxx_lookup() --> {inode = xxx_iget(_sb, )} --> {init i_op & i_fop}
-
do_last()
-
lookup_open() --> may_open() --> {if (path->mnt->mnt_flags & MNT_NODEV) return -EACCES}
-
V
-
//xxx_lookup->new_inode|xxx_iget()->new_inode_pseudo()->alloc_inode()
-
//'.->i_fop =' {inode->i_fop = de->proc_fops;},{inode->i_fop = &xxx_file_ops;}
-
//finish_open()->do_dentry_open()->{f->f_op = fops_get(inode->i_fop);}
-
//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,