Chinaunix首页 | 论坛 | 博客
  • 博客访问: 72783
  • 博文数量: 172
  • 博客积分: 2047
  • 博客等级: 大尉
  • 技术积分: 1745
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-19 15:23
文章分类

全部博文(172)

文章存档

2011年(72)

2010年(100)

我的朋友

分类: LINUX

2010-05-19 17:51:28


节点操作 初始化
vfs inode  vfs file vfs adress_space

fuse中初始化inode节点的操作

void fuse_init_file_inode(struct inode *inode)
{
    inode->i_fop = &fuse_file_operations;
    inode->i_data.a_ops = &fuse_file_aops;
}


以下是两个结构的具体填充。

static struct file_operations fuse_file_operations = {
    .llseek        = generic_file_llseek,
#ifndef KERNEL_2_6_19_PLUS
    .read        = generic_file_read,
    .write        = generic_file_write,
#else
    .read        = do_sync_read,
    .aio_read    = generic_file_aio_read,
    .write        = do_sync_write,
    .aio_write    = generic_file_aio_write,
#endif
    .mmap        = fuse_file_mmap,
    .open        = fuse_open,
    .flush        = fuse_flush,
    .release    = fuse_release,
    .fsync        = fuse_fsync,
    .lock        = fuse_file_lock,
#ifdef KERNEL_2_6_23_PLUS
    .splice_read    = generic_file_splice_read,
#else
    .sendfile    = generic_file_sendfile,
#endif
};



static struct address_space_operations fuse_file_aops = {
    .readpage = fuse_readpage,
    .prepare_write = fuse_prepare_write,
    .commit_write = fuse_commit_write,
    .readpages = fuse_readpages,
    .set_page_dirty = fuse_set_page_dirty,
    .bmap = fuse_bmap,
}


还有另外一个结构也进行了相关的填充。该结构在direct_io时使用。用户如果选择了改模式的选项则操作
会按提供的这类接口实现来完成操作。

static struct file_operations fuse_direct_io_file_operations = {
    .llseek        = generic_file_llseek,
    .read        = fuse_direct_read,
    .write        = fuse_direct_write,
    .open        = fuse_open,
    .flush        = fuse_flush,
    .release    = fuse_release,
    .fsync        = fuse_fsync,
    .lock        = fuse_file_lock,
    /* no mmap and sendfile */
};


实际的操作跟踪分析,有几个函数使用了fuse_init_file_inode

查看fuse_lookup fuse_lookup

fuse_lookup 作为inode_oprations 中的一个实现。

static struct inode_operations fuse_dir_inode_operations = {
    .lookup        = fuse_lookup,
    .mkdir        = fuse_mkdir,
    .symlink    = fuse_symlink,
    .unlink        = fuse_unlink,
    .rmdir        = fuse_rmdir,
    .rename        = fuse_rename,
    .link        = fuse_link,
    .setattr    = fuse_setattr,
    .create        = fuse_create,
    .mknod        = fuse_mknod,
    .permission    = fuse_permission,
    .getattr    = fuse_getattr,
    .setxattr    = fuse_setxattr,
    .getxattr    = fuse_getxattr,
    .listxattr    = fuse_listxattr,
    .removexattr    = fuse_removexattr,
};


调用处。

void fuse_init_dir(struct inode *inode)
{
    inode->i_op = &fuse_dir_inode_operations;
    inode->i_fop = &fuse_dir_operations;
}


从以上的跟踪过程可以看出操作对应的填充关系。应该说这是一种静态的方式。
接下来分析具体inode初始化的整个过程。
阅读(1429) | 评论(0) | 转发(0) |
0

上一篇:vfs fuse 的多线程场景分析

下一篇:vfs inode

给主人留下些什么吧!~~