Chinaunix首页 | 论坛 | 博客
  • 博客访问: 286073
  • 博文数量: 60
  • 博客积分: 2697
  • 博客等级: 少校
  • 技术积分: 653
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-13 15:52
文章分类

全部博文(60)

文章存档

2012年(6)

2011年(31)

2010年(23)

分类: LINUX

2010-11-27 18:49:27

    Fist生成的堆叠式文件系统代码如下:
  1. #define INODE_TO_LOWER(ino) (INODE_TO_PRIVATE(ino)->wii_inode)
  2. #define INODE_TO_PRIVATE(ino) (container_of(ino, struct XXXfs_inode_info, vfs_inode))
  3. #define container_of(ptr, type, member) ({ \  //container_of实现了根据一个结构体变量中的一个域成员变量的指针来获取指向整个结构体变量的指针的功能
  4. const typeof( ((type *)0)->member ) *__mptr = (ptr); \ //声明一个与member同一个类型的指针常量 *__mptr,并初始化为ptr
  5. (type *)( (char *)__mptr - offsetof(type,member) );}) //__mptr的地址减去member在该struct中的偏移量得到的地址, 再转换成type型指针. 该指针就是member的入口地址了
  6. * container_of - cast a member of a structure out to the containing structure
  7. //将某个结构成员放入另一个容器结构中,
  8.   如INODE_TO_PRIVATE(struct inode *inode),可以通过给定的inode找到容纳inode成员的结构指针
  9. * @ptr: the pointer to the member. //成员指针
  10. * @type: the type of the container struct this is embedded in. //嵌入的容器结构类型
  11. * @member: the name of the member within the struct. //该成员在容器中的名称
 
 
阅读(848) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~